-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpre_post.c
More file actions
22 lines (18 loc) · 783 Bytes
/
pre_post.c
File metadata and controls
22 lines (18 loc) · 783 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// increment_operators.c
// Problem Statement:
// - Demonstrate the difference between pre-increment and post-increment operators in C.
// - Use a series of `printf` statements to observe the changes in the value of `i`.
#include<stdio.h>
int main(){
int i = 9;
printf("The value of i is %d\n", i);
printf("The value of i is %d\n", ++i);
printf("The value of i is %d\n", i++);
printf("The value of i is %d\n", i);
return 0;
}
// Working:
// - The program initializes `i` to 9.
// - It demonstrates pre-increment (`++i`), where `i` is incremented before use.
// - It also demonstrates post-increment (`i++`), where the value of `i` is used first, then incremented.
// - The changes in the value of `i` are printed after each operation.