#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
How can I check whether a file exists? I want to warn the user if a requested input file is missing.
Is there a way to switch on strings?
Do you know the use of 'auto' keyword?
In c programming, explain how do you insert quote characters (? And ?) Into the output screen?
What is the difference between pure virtual function and virtual function?
hw can we delete an internal node of binary search tree the internal node has child node..plz write progarm
Is there a built-in function in C that can be used for sorting data?
What is the use of pointers in C?
What is the difference between #include and #include 'file' ?
What are the advantages of c language?
What is a union?
Tell me can the size of an array be declared at runtime?
What is linear search?
Why we use conio h in c?
What is a good data structure to use for storing lines of text?