Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

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

4361


writ a program to compare using strcmp VIVA and viva with its output.

2082


What do header files do?

1139


Explain the difference between call by value and call by reference in c language?

1161


Explain what are reserved words?

1160


Is sizeof a keyword in c?

1014


What is the concatenation operator?

1208


Find duplicates in a file containing 6 digit number (like uid) in O (n) time.

3309


praagnovation

2350


what will be maximum number of comparisons when number of elements are given?

1952


Why does everyone say not to use scanf? What should I use instead?

1470


How can I read in an object file and jump to locations in it?

1071


Explain which of the following operators is incorrect and why? ( >=, <=, <>, ==)

1087


How do I determine whether a character is numeric, alphabetic, and so on?

1183


What is the difference between ‘g’ and “g” in C?

4091