Wednesday, February 10, 2010

What is the output of this program?

main()
{
struct
{
int i;
}xyz;
(*xyz)->i=10;
printf("%d",xyz.i);
}

a) program will not compile
b) 10
c) god only knows
d) address of i

Monday, February 8, 2010

What is the output of following programme ?

# include
# define a 10
main()
{
printf("%d..",a);
foo();
printf("%d",a);
}
void foo()
{
#undef a
#define a 50
}

a) 10..10
b) 10..50
c) Error
d) 0

What does the following program print?

int a[3][3] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};

main()
{
int i;
for(i = 0; i < 3; i++)
 printf("%d%d%d", a[i][2-i], *a[i], *(*(a+i)+i));
}

 a) 3 1 1
     5 4 5
     7 7 9
 b) 7 1 1
    5 4 5
    3 7 9
 c) 3 1 1
    5 4 7
    7 7 9
 d) 3 5 7
    1 4 7
    1 7 9

The output of printf("%u", -1) is

a) -1
b) Minimum int value
c) Maximum int value
d) Error message

The printf() function retunes which value when an error occurs?

a) Positive value
b) Zero
c) Negative value
d) None of these