Home / Programs / Example of Increment and Decrement operator in cprogramming langauage
🚀 Programming Example

Example of Increment and Decrement operator in cprogramming langauage

👁 987 Views
💻 Practical Program
📘 Step Learning
Imagine you have operation as below num = num + 1; you can simply this syntax use ++. num++; using the same approach for this case num = num - 1; you can use — syntax. num--; Now how to implement them in code. Let’s write this code.

💻 Program Code

#include <stdio.h>
int main() {
	int a = 10;
	a++;
	printf("%d \n",a);
	a++;
	printf("%d \n",a);
	++a;
	printf("%d \n",a);
	a--;
	printf("%d \n",a);
	a--;
	printf("%d \n",a);
	--a;
	printf("%d \n",a);
	return 0;
}
                        

🖥 Program Output

11
12
13
12
11
10
Press any key to continue . . .
                            

📘 Explanation

None
📚 Learning Subject

Master Programming Through Practical Examples

Improve your coding logic, problem-solving skills and programming confidence by practicing real-world examples with explanations.

🎯 How to learn from this example

First understand the algorithm carefully. Then study the program line-by-line and compare it with the output. Finally, review the explanation section to strengthen your logic and programming understanding.

🔥 Practice suggestion

Rewrite the program without looking at the code. Modify values, conditions or logic and run it again. This helps improve confidence and strengthens coding skills much faster.