#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
Is c pass by value or reference?
What does %2f mean in c?
how to execute a program using if else condition and the output should enter number and the number is odd only...
Explain what would happen to x in this expression: x += 15; (assuming the value of x is 5)
What is printf () in c?
what is use of malloc and calloc?
Which is more efficient, a switch statement or an if else chain?
Does free set pointer to null?
Linked lists -- can you tell me how to check whether a linked list is circular?
general for is %wd,f-d; in this system "w" means a) 'w' represent total width of digits b) 'w' represent width which includes the digits before,after decimal place and the decimal point c) 'w' represent width which includes the digits before only d) 'w' represent width after decimal place only
What is volatile c?
What should malloc(0) do? Return a null pointer or a pointer to 0 bytes?
Why c is called a mid level programming language?
What do you mean by Recursion Function?
Tell me the use of bit field in c language?