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 else if ladder?
Explain is it better to bitshift a value than to multiply by 2?
Describe the complexity of Binary search, Quicksort and various other sorting and searching techniques..
What is bubble sort technique in c?
What does it mean when the linker says that _end is undefined?
Is struct oop?
What is the difference between typedef struct and struct?
What do you mean by a local block?
Write a program to print fibonacci series using recursion?
What is the use of header?
how can I convert a string to a number?
Why do we use stdio h and conio h?
Where can I get an ansi-compatible lint?
What are the advantages of c preprocessor?
If fflush wont work, what can I use to flush input?