Arithmetic operators are used to perform common mathematical operations.
Operator | Name | Description | Example |
---|---|---|---|
+ | Addition | Adds together two values | x + y |
- | Subtraction | Subtracts one value from another | x - y |
* | Multiplication | Multiplies two values | x * y |
/ | Division | Divides one value by another | x / y |
% | Modulus | Returns the division remainder | x % y |
++ | Increment | Increases the value of a variable by 1 | x++ |
-- | Decrement | Decreases the value of a variable by 1 | x-- |
#include<stdio.h>
int main() {
int x = 5;
int y = 3;
printf("%d", x + y);
return 0;
}
#include<stdio.h>
int main() {
int x = 5;
int y = 3;
printf("%d", x - y);
return 0;
}
#include<stdio.h>
int main() {
int x = 5;
int y = 3;
printf("%d", x * y);
return 0;
}
#include<stdio.h>
int main() {
int x = 5;
int y = 3;
printf("%d", x / y);
return 0;
}
#include<stdio.h>
int main() {
int x = 5;
int y = 3;
printf("%d", x % y);
return 0;
}
#include<stdio.h>
int main() {
int x = 5;
int y = 3;
printf("%d", ++x);
return 0;
}
#include<stdio.h>
int main() {
int x = 5;
int y = 3;
printf("%d", --x);
return 0;
}