Arithmetic Operators in C

Arithmetic Operators in C

Arithmetic operators are used to perform mathematical calculations in a program. Various arithmetic operators in C language are as follows:

1. +

Addition operator is represented as plus (+) sign. It is used to add values of numeric variables, constants or expressions.

Example

11 + 3 = 14

2. –

Subtraction operator is represented as a hyphen (-). It is used to subtract value of one numeric quantity from another.

Example

11 – 3 = 8

3. *

Multiplication operator is represented as an asterisk (*). It is used to multiply value of one numeric quantity with another numeric quantity.

Example

11 * 3 = 33

4. / 

Division operator is represented as a forward slash (/). It is used to divide value of one numeric quantity by another numeric quantity.

Example

11 / 3 = 3

5. %

Modulus operator is represented as a percent sign(%). It returns remainder after dividing one numeric quantity by another numeric quantity.

Example :

10 % 3 =1

Program to demonstrate arithmetic operators.
#include<stdio.h>
int  main()
{
int a=10,b=3,c;
c=a+b;
printf(“\na+b=%d”,c);   /*a+b=13*/
c=a-b;
printf(“\na-b=%d”,c);   /*a-b=7*/
c=a*b;
printf(“\na*b=%d”,c);    /*a*b=30*/
c=a/b;
printf(“\na/b=%d”,c);     /*a/b=3*/
c=a%b;
printf(“\na%%b=%d”,c);  /*a%b=1*/
getch();
return (0);
}

 


Spread the love
Lesson tags: Arithmetic Operators in C, C Operators
Back to: C Programming Language
Spread the love