C language supports all the basic arithmetic operations. addition, subtraction, multiplication and subtraction are performed on numerical data types like
int
, float, doubleThe different arithmetic operators are shown in Table
Operator | Description |
---|---|
+ | Addition |
_ | Subtraction |
* | Multiplication |
/ | Division |
% | Modulus |
++ | Increment Operator increases integer value by one |
-- | Decrement Operator decreases integer value by one |
Program:
Output:
#include <stdio.h>
int main()
{
int num1, num2;
int sum, sub, mult, mod;
float div;
printf("Enter two numbers:\n");
scanf("%d%d", &num1, &num2);
sum = num1 + num2;
sub = num1 - num2;
mult = num1 * num2;
div = (float)num1 / num2;
mod = num1 % num2;
printf("Sum = %d\n", sum);
printf("Differance = %d\n", sub);
printf("Product = %d\n", mult);
printf("Quotient = %f\n", div);
printf("Modulus = %d", mod);
return 0;
}
Output: