what will be the output of this program?
void main()
{
int a[]={5,10,15};
int i=0,num;
num=a[++i] + ++i +(++i);
printf("%d",num);
}
Answer Posted / apekshit jotwani
Answer will be 15.
Consider a[++i]=x
++i=y
++i=z
so v have to evaluate x+y+z
Compiler converts this to postfix as "xy+z+"
so x is put in the stack 1st i=1,x=a[1]=10
Then i=2, 2 is put in the stack
Then x+y is operated = 12
12 is put in the stack.
Then i=3, 3 is put in the stack.
Then 12+3=15,
only 15 is put in the stack. That is the final answer
| Is This Answer Correct ? | 3 Yes | 0 No |
Post New Answer View All Answers
What is #define size in c?
Write a program to swap two numbers without using third variable?
Explain what is wrong with this program statement? Void = 10;
Why double pointer is used in c?
What is the difference between near, far and huge pointers?
What is a lvalue
What are structure members?
Tell us something about keyword 'auto'.
What are the types of unary operators?
What are the advantages of external class?
Can variables be declared anywhere in c?
Explain void pointer?
praagnovation
Can we compile a program without main() function?
in iso what are the common technological language?