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
How can I sort more data than will fit in memory?
Explain the difference between malloc() and calloc() function?
How can I discover how many arguments a function was actually called with?
What are the types of operators in c?
What is the use of printf() and scanf() functions?
write a c program thal will find all sequences of length N that produce the sum is Zero, print all possible solutions?
how to print electricity bill according to following charges first 100 units -1rs per unit for next 200 units-1.50 rs per unit without using conditions
what is a constant pointer in C
Can the size of an array be declared at runtime?
There is a practice in coding to keep some code blocks in comment symbols than delete it when debugging. How this affect when debugging?
Why isn't it being handled properly?
Write program to remove duplicate in an array?
What do you mean by dynamic memory allocation in c? What functions are used?
Explain Function Pointer?
What is the value of h?