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

What are the various types of control structures in programming?

0 Answers  


#include<stdio.h> main() {int i=1;j=1; for(;;) {if(i>5) break; else j+=1; printf("\n%d",j) i+=j; } }

7 Answers   HCL,


What is the use of pointers in C?

0 Answers   Impetus, Motorola, Tavant Technologies, Virtusa,


Why do we need volatile in c?

0 Answers  


can we write a c program with out using main

3 Answers  






Write an algorithm for a program that receives an integer as input and outputs the product of of its digits. E.g. 1234 = 24, 705 = 0

4 Answers  


which of the following is not a character constant a) 'thank you' b) 'enter values of p, n ,r' c) '23.56E-o3' d) all of the above

0 Answers  


What are near, far and huge pointers?

0 Answers   Hexaware, Thomson Reuters, Virtusa,


What would be an example of a structure analogous to structure c?

0 Answers  


What is the difference between File pointer and Internal Charecter Pointer?

2 Answers   TATA,


how to find out the inorder successor of a node in a tree??

2 Answers   TCS, Yahoo,


How many ways are there to swap two numbers without using temporary variable? Give the each logic.

9 Answers  


Categories