Question Bank (3 marks) · Q15
Q.Write a C program to illustate the use of increment operator.
Karnataka PUCTextbookLong· 3mImportance★★★★★est
50% · 77/154 Questions
You're viewing a preview — the full solution, concept, methods & PYQ mapping are locked.
Start your 14-day free trial to unlock the full solution →[!TLDR]
The ++ operator adds 1 to a variable; a++ uses the value then increments, while ++a increments then uses the value.
The increment operator ++ increases the value of its operand by 1. It has two forms:
- Post-increment (a++): the current value is used in the expression first, and then the variable is increased.
- Pre-increment (++a): the variable is increased first, and the new value is used in the expression.
#include <stdio.h>
int main()
{
int a = 5, b;
b = a++; /* post: b gets 5, then a becomes 6 */
printf("Post-increment: a = %d, b = %d\n", a, b);
a = 5;
b = ++a; /* pre: a becomes 6, then b gets 6 */ …
Unlock everything free for 14 days
- Full step-by-step solutions
- Concept-first explanations
- Methods, shortcuts & mistakes
- PYQ mapping + timed mock tests
Full access for 14 days. No credit card required.