Campus interview zone
Would you like to react to this message? Create an account in a few clicks or log in to continue.

What is the output of following-12

Go down

What is the output of following-12 Empty What is the output of following-12

Post  Admin Sun Jan 31, 2010 7:59 am

34) void main()
{
int i=5;
printf("%d",i++ + ++i);
}
Answer:
Output Cannot be predicted exactly.
Explanation:
Side effects are involved in the evaluation of i
35) void main()
{
int i=5;
printf("%d",i+++++i);
}
Answer:
Compiler Error
Explanation:
The expression i+++++i is parsed as i ++ ++ + i which is an illegal combination of operators.
36) #include<stdio.h>
main()
{
int i=1,j=2;
switch(i)
{
case 1: printf("GOOD");

break;
case j: printf("BAD");
break;
}
}
Answer:
Compiler Error: Constant expression required in function main.
Explanation:
The case statement can have only constant expressions (this implies that we cannot use variable names directly so an error).
Note:
Enumerated types can be used in case statements.

Admin
Admin

Posts : 71
Join date : 2010-01-21

http://campus-interview.co.cc

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum