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
Calculate the weighted average of a list of n numbers using the formula xavg = f1x1+f2x2+ ….+ fnxn where the f’s are fractional weighting factors, i.e., 0<=fi<1, and f1+f2+….+fn = 1
writ a program to compare using strcmp VIVA and viva with its output.
What do header files do?
Explain the difference between call by value and call by reference in c language?
Explain what are reserved words?
Is sizeof a keyword in c?
What is the concatenation operator?
Find duplicates in a file containing 6 digit number (like uid) in O (n) time.
praagnovation
what will be maximum number of comparisons when number of elements are given?
Why does everyone say not to use scanf? What should I use instead?
How can I read in an object file and jump to locations in it?
Explain which of the following operators is incorrect and why? ( >=, <=, <>, ==)
How do I determine whether a character is numeric, alphabetic, and so on?
What is the difference between ‘g’ and “g” in C?