#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
A collection of data with a given structure for excepting storing and providing on demand data for multiple users a) linked list b) datastructer c) database d) preprocessor
Is there sort function in c?
What is malloc return c?
What does s c mean on snapchat?
Explain what is wrong with this program statement?
What is the purpose of void in c?
How is a pointer variable declared?
‘ C’ PROGRAME TO SHOW THE TYPE OF TRANGLE BY ACCEPTING IT’S LENGTH .
Can main () be called recursively?
How can I find out if there are characters available for reading?
Explain how many levels deep can include files be nested?
What are enumerated types?
Why is sizeof () an operator and not a function?
What does a function declared as pascal do differently?
Do you know the use of fflush() function?