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 are the 4 types of programming language?
What is the difference between far and near in c?
What are directives in c?
Is it possible to use curly brackets ({}) to enclose single line code in c program?
Are comments included during the compilation stage and placed in the EXE file as well?
An arrangement of information in memory in such a way that it can be easily accessed and processed by a programming language a) string b) data structure c) pointers d) array
What is a structure in c language. how to initialise a structure in c?
How will you declare an array of three function pointers where each function receives two ints and returns a float?
What extern c means?
What is a memory leak? How to avoid it?
What is the use of a semicolon (;) at the end of every program statement?
What are the different file extensions involved when programming in C?
Can you pass an entire structure to functions?
how to capitalise first letter of each word in a given string?
What is mean by data types in c?