The following program
main()
{
int i = 2;
{ int i = 4, j = 5;
printf ("%d%d", i, j );
}
printf("%d%d", i, j );
}
A. | will not compile successfully |
B. | prints 4525 |
C. | prints 2525 |
D. | none of above |
Option: A Explanation : This will not compile successfully. The scope of the variable ' j ' is the single printf statement that follows it. So. the last statement that involves ' j ' will complain about the undeclared identifier ' j ' Click on Discuss to view users comments. |
printf("ab", "cd", "ef");
prints
A. | ab |
B. | abcdef |
C. | abcdef, followed by garbage |
D. | none of above |
Option: A Explanation : Click on Discuss to view users comments. |
main( )
(
int a = 5, b = 2;
printf("%d", a+++b);
}
A. | results in syntax error |
B. | prints 7 |
C. | prints 8 |
D. | none of above |
Option: B Explanation : The compiler will tokenize a + + + b as a, + +, b. So, a + + b is equivalent to a + + + b, which evaluates to 7 Click on Discuss to view users comments. |
A possible output of the following program fragment
static char wer [ ] [5] = { "harmot", "merli", "axari" };
printf({"%d%d%d", wer, wer[0], &wer[0][0]);
is
A. | 262164 262164 262164 |
B. | 262164 262165 262166 |
C. | 262164 262165 262165 |
D. | 262164 262164 262165 |
Option: A Explanation : Click on Discuss to view users comments. |
The following program
main( )
{
printf ("%u", main);
}
results in
A. | printing of a garbage number |
B. | an execution error |
C. | printing of starting address of the function main |
D. | an infinite loop |
Option: C Explanation : Like array name, name of a function is a pointer to it. Click on Discuss to view users comments. |