C Programming :: Declarations and Initializations - Discussion
22 / 54
#include<stdio.h>
void main()
{
int a,b,c;
b=2;
a= 2*(b++);
c = 2*(++b);
}
#include<stdio.h>
void main()
{
int a,b,c;
b=2;
a= 2*(b++);
c = 2*(++b);
}
Aa=4,c=6
Ba=3,c=8
Cb=3, c=6
Da=4, c=8
ENone of these
Show Explanation
b=2;
a= 2*(b );..........a=2*2=4 Here post increment of b will take place and b value after this line has executed will become 2 1= 3.
c = 2*( b); Here pre increment will take place and before the excecution of this line b value will become 3 1=4 hence c= 2*4=8
so o/p= a=4 and c=8.
Asked In ::
b=2;
a= 2*(b );..........a=2*2=4 Here post increment of b will take place and b value after this line has executed will become 2 1= 3.
c = 2*( b); Here pre increment will take place and before the excecution of this line b value will become 3 1=4 hence c= 2*4=8
so o/p= a=4 and c=8.
Read Full Answer
Report Error
Please Login First Click Here
The value of 'a' is calculated as:-
a=2*(b++)
or, a=2*(2) [Since, here 'b' is post-incremented]
Therefore, a=4
Now, value of 'b' will be 2+1=3, due to post-increment.
Finally, c=2*(++b)
or, c=2*(4) [Since, here 'b' is pre-incremented]
Therefore, c=8
Read Full Answer
Report Error
Please Login First Click Here