?
Consider the following program fragment, and choose the correct one.
Consider the following program fragment, and choose the correct one.
void main()
{
int a, b = 2, c;
a = 2 * (b++);
c = 2 * (++b);
}
void main()
{
int a, b = 2, c;
a = 2 * (b++);
c = 2 * (++b);
}
Join the Discussion
Login to post a comment or share your explanation.
LoginNOW it's a increment operator then Frist b++ and ++b it's two times increment that's way b=4
B++ is Frist assign the value again increment this is postinremnt that's way after ans this is 3 and ++b is b=b+1 this is 4
b++ = 3 in 1st condition
++b =4 due to 1st condition