-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharithmeticOperators.c
More file actions
38 lines (30 loc) · 858 Bytes
/
Copy patharithmeticOperators.c
File metadata and controls
38 lines (30 loc) · 858 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <stdio.h>
int main()
{
// arithmetic operators = + - * / % ++ --
// Do arithmetic operatiions with x and y and store the resul in z
int x = 2;
int y = 3;
// float y = 3; // for Integer division.
int z = 0;
// float z = 0; // for Integer division.
z = x + y;
/*
Remove the multiline comment and try one operation and assignment to z at a time.
z = x + y;
z = x - y;
z = x * y;
z = x / y; // Integer division result should be stored in float.
z = x % y; // modulus or remainder of division
z = x ++; // x = x + 1, increment operator
z = x --; // decrement operator
Augmented Assignment Operator:
x+=3; // x = x+3
x-=3; // x = x-3
x*=2; // x = x*2
x/=2; // x = x/2
*/
printf("%d", z);
// printf("%f", z); // for integer division
return 0;
}