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 does & mean in scanf?
How do you generate random numbers in C?
Are the variables argc and argv are local to main?
Explain how do you use a pointer to a function?
What do you mean by c what are the main characteristics of c language?
How many main () function we can have in a project?
What is a node in c?
which is an algorithm for sorting in a growing Lexicographic order
What are the functions to open and close the file in c language?
What is header file definition?
What is the use of function in c?
What is s in c?
why use functions a) writing functions avoids rewriting the same code over and over b) using functions it becomes easier to write programs and keep track of what they are doing c) a & b d) none of the above
What are the different file extensions involved when programming in C?
What is adt in c programming?