Pre-increment Vs Post-increment Operators- MCQ for Practice & Explanation

Pre-increment Vs Post-increment operators. What’s the difference between pre-increment (++i) and post-increment (i++) operators.  In this post, we’ll learn how pre-increment and post-increment operators work in programming.

In this post, You’ll find MCQ which will help you to understand this concept fully.

MCQ on recursion

Pre-increment Vs Post-increment Operators

Pre-increment (++i)

When we use pre-increment operator, The value is first incremented and the used in an expression.

For example –

Post-increment (i++)

In post-increment, The current value is used in an expression and after that, it’s incremented.

For example –

C Objective Tricky Questions

Program to print triangle pattern of number and stars

MCQ on Pre-increment and Post-increment Operators

1.

a) 4, 3, 3

b) 3, 3, 3

c) 2, 3, 3

d) 4, 4, 3

2.

a) a = 6, b = 15

b) a =1 , b = 3

c) a = 1 , b =15

d) a = 2 , b = 4

3.

a) 9, 9

b) 10, 10

c) 9, 10

d) 10, 9

4.

a) 24, 12

b) 23, 12

c) 23, 10

d) 24, 10

Solutions and Explanation

Ans1.  C)  2, 3, 3

int x=4,  y,  z;

y = –x; . In this statement value of x is first decrement then assigned. So value of y is 3 and after decrement value of x is 3.

z = x–; . Now value of x is 3. This is post-decrement operation value is first assigned and then decrement. So value of z is 3.

Now the current value of x is 2.

Ans 2 a) a = 6, b = 15

Ans 3 b)  10, 10

Ans 4 a)  24, 12

Difference between pre-increment and post-increment video tutorial

Tagged , , , , . Bookmark the permalink.

About WebRewrite

I am technology lover who loves to keep updated with latest technology. My interest field is Web Development.