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);
}

Answers were Sorted based on User's Feedback



what will be the output of this program? void main() { int a[]={5,10,15}; int i=0,num; num=a[++..

Answer / gerda

15

Is This Answer Correct ?    5 Yes 0 No

what will be the output of this program? void main() { int a[]={5,10,15}; int i=0,num; num=a[++..

Answer / 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

what will be the output of this program? void main() { int a[]={5,10,15}; int i=0,num; num=a[++..

Answer / ricky

Garbage Value

num=a[++i] + ++i +(++i);
in this line the last i will be incremented first
so the last ++i will return 1 after that the middle ++i will return 2 now the value of i will change every where in the program now the first ++i will return 3 since the array starts with a[0] and ends at a[2] there is no a[3] and hence it will print garbage value

Is This Answer Correct ?    5 Yes 3 No

what will be the output of this program? void main() { int a[]={5,10,15}; int i=0,num; num=a[++..

Answer / abc

initially i=0;
num=a[++i]+ ++i + ++i;
num=a[1]+2+3
num=10+2+3=15

Is This Answer Correct ?    1 Yes 0 No

what will be the output of this program? void main() { int a[]={5,10,15}; int i=0,num; num=a[++..

Answer / babu ba

6

Is This Answer Correct ?    3 Yes 3 No

what will be the output of this program? void main() { int a[]={5,10,15}; int i=0,num; num=a[++..

Answer / girish

15

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C Interview Questions

Write a C/C++ program that connects to a MySQL server and checks intrusion attempts every 5 minutes. If an intrusion attempt is detected beep the internal speaker to alert the administrator. A high number of aborted connects to MySQL at a point in time may be used as a basis of an intrusion.

2 Answers   Drona Solutions, Infosys, Vodafone, Webyog,


how does the for loop work actually..suppose for the following program how it ll work plz explain to me for(i=5;i>=0;i--) prinf(i--);

19 Answers   RMSI,


Look at the Code: main() { int a[]={1,2,3},i; for(i=0;i<3;i++) { printf("%d",*a); a++; } } Which Statement is/are True w.r.t the above code? I.Executes Successfully & Prints the contents of the array II.Gives the Error:Lvalue Required III.The address of the array should not be changed IV.None of the Above. A)Only I B)Only II C)II & III D)IV

5 Answers   Accenture,


How can a program be made to print the name of a source file where an error occurs?

0 Answers  


in a town the percentage of men is 52 the percentage of total literacy is 48 if total percentage of literate men is 35 of the total population write a program to find the total no of the literate men and women if the population of the town is 80000

3 Answers  






I need a help with a program: Write a C program that uses data input in determining the whole of points A and a whole of circles B. Find two points in A so that the line which passes through them, cut through the maximum number of circles.

0 Answers   TCS,


Write a program to print fibonacci series using recursion?

0 Answers  


Why c is called object oriented language?

0 Answers  


Differentiate between the expression “++a” and “a++”?

0 Answers  


Can we change the value of #define in c?

0 Answers  


Explain About fork()?

0 Answers   TISL,


write a program that declares an array of 30 elements named "income" in the main functions. then cal and pass the array to a programmer-defined function named "getIncome" within the "getIncome" function, ask the user for annual income of 30 employees. then calculate and print total income on the screen using the following function: "void getIncome ( ai []);

0 Answers   TCS,


Categories