ExamVeda
Login
Home
Operators and Expressions
?

Consider the following program fragment, and choose the correct one.
void main()
{
   int a, b = 2, c;
   a = 2 * (b++);
   c = 2 * (++b);
}

Answer & Solution
Correct Answer: Option A
Let's discuss the solution. Join the discussion
Examveda
Question posted by Examveda
Community

Join the Discussion

3 Comments
Prathamesh Kiran
Prathamesh Kiran 4 years ago
Frist b++ is 2 now Frist ans is 2*2=4
NOW 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
Harshal Chaudhari
Harshal Chaudhari 8 years ago
Plz explain this pro
Sagar Gurao
Sagar Gurao 10 years ago

b++ = 3 in 1st condition
++b =4 due to 1st condition