Example 1: Write a program to use Arithmetic Operator(+, -, /, *, %) 1
#include<stdio.h>
void main()
{
int a=2, b=3;
int sum, sub, mul, idiv, mod;
float fdiv;
sum = a + b;
sub = a - b;
mul = a * b;
idiv = a / b;
fdiv = (float)a / b;
mod = b%a;
printf("\nSum = %d",sum);
printf("\nSub = %d",sub);
printf("\nMul = %d",mul);
printf("\niDiv = %d",idiv);
printf("\nfDiv = %f",fdiv);
printf("\nMod = %d",mod);
}
Modulus Operator: It divides the number and returns the remainder. Modulus operator will work only with integer and character, it will not work with float and double data types.