Preview
Arithmetic Operators in C
These operators are used to perform mathematical calculations in a program. Various arithmetic operators in C language are as follows:
1. +
Addition operator (+) is used to add numeric values.
Example
11 + 3 = 14
2. –
Subtraction operator (-) is used to subtract one numeric quantity from another value.
Example
11 – 3 = 8
3. *
Multiplication operator (*) is used to multiply values of numeric quantities.
Example
11 * 3 = 33
4. /
Division operator (/) is used to divide one number by another number.
Example
11 / 3 = 3
5. %
Modulus operator (%) divides one number by another number to give remainder.
Example :
20 % 3 =2
Program to demonstrate arithmetic operators. | Output |
#include<stdio.h> int main() { int a,b,c; a=20; b=3; |
|
c=a+b; printf(“\n%d”,c); |
23 |
c=a-b; printf(“\n%d”,c); |
17 |
c=a*b; printf(“\n%d”,c); |
60 |
c=a/b; printf(“\n%d”,c); |
6 |
c=a%b; printf(“\n%d”,c); |
2 |
return (0); } |
Best Books of Computer Science