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

Explain what does it mean when a pointer is used in an if statement?

1004


Differentiate fundamental data types and derived data types in C.

983


Which built-in library function can be used to match a patter from the string?

1236


write a proram to reverse the string using switch case?

2880


What is the difference between exit() and _exit() function in c?

1016


how do you write a function that takes a variable number of arguments? What is the prototype of printf () function?

1895


Can you explain what keyboard debouncing is, and where and why we us it? please give some examples

2144


What is keyword with example?

1009


What does %p mean?

1031


How do you print an address?

1207


to find the closest pair

2288


What is the main difference between calloc () and malloc ()?

1094


What are the similarities between c and c++?

1001


Write a program to print all permutations of a given string.

1126


What is C language ?

1901