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...

#include<stdio.h>
main()
{
int a=1;
int b=0;
b=++a + ++a;
printf("%d %d",a,b);
}

Answer Posted / aditya gupta

Let me make this more clear... infact if the case is of
pre-increment:

1- find all the variables of pre-increment, and compute them
2- do the assignment.

for example, what I do:
main()
{
int a=1; // initialization
int b=0; // initialization

b=++a + ++a; // find the pre-increment i.e. 2 increments of
'a' so now 'a' in this step will be incremented by 2 so now
'a' will contain 1+2=3. so now a=3. Again before assignment
compute 'a+a' which is '3+3'=6

printf("%d %d",a,b); //3 6

}

Just a trick:- always compute the pre-increments in the same
step...

If I say b= ++a + ++a; answer is 3 and 6
If I say b= ++a + a++; answer is 3 and 4 because in this
line one pre-increment is there. So now '++a + a++'= "2 + 2"



Thanks!!
Aditya Gupta

Is This Answer Correct ?    8 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Write program to remove duplicate in an array?

1049


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

1108


Explain how many levels deep can include files be nested?

1041


What is 2c dna?

1037


What are dangling pointers in c?

1155


program to find out date after adding 31 days to a date in the month of febraury also consider the leap year

3049


how to print electricity bill according to following charges first 100 units -1rs per unit for next 200 units-1.50 rs per unit without using conditions

3150


How macro execution is faster than function ?

1152


Difference between pass by reference and pass by value?

1114


Explain what are its uses in c programming?

1038


A global variable when referred to in another file is declared as this a) local variable b) external variable c) constant d) pointers

1144


What is a MAC Address?

1023


Is array name a pointer?

1010


What is the purpose of the statement: strcat (S2, S1)?

1127


How can I call fortran?

1007