## Arithmetic operator in C

Most C programs use arithmetic calculations. In algebra, if we want to multiply a times b, we can simply write ab. But C, if we want to do that we must write a*b, if we write ab it show error or string "ab". Therefore, C (and other programming languages) require that using the * operator as in a * b

The arithmetic operators are all binary operators. For example, the expression 1 + 2 has the binary operator + and the operands 1 and 2.

The remainder operator is an integer operator that is used only with integer operands.

In table you can find all arithmetic operators:

C operation | Arithmetic operator | C expression |
---|---|---|

Addition | + | a+b |

Subtraction | - | a-b |

Multiplication | * | a*b |

Division | / | a/b |

Remainder | % | a%b |

**Example:**

`#include <stdio.h>`

#include <stdlib.h>

int main(int argc, char *argv[]){

int number1;//first number inputed by user

int number2;//second number inputed by user

int sum;//variable for addition of two numbers

int sub;//variable for subtraction of two numbers

int mult;//variable for multiplication of two numbers

float div;//variable for division of two numbers

int remainder;//variable for remainder of two number

printf("Enter first number: ");

scanf("%d",&number1);//Read first number

printf("Enter second number: ");

scanf("%d",&number2);//Read second number

//Addition two numbers

sum=number1+number2;

//subtraction two numbers

sub=number1-number2;

//multiplication two number

mult=number1*number2;

//division two numbers

div=(float)number1/(float)number2; //(float) it is use for converting int to float

//remainder two numbers

remainder=number1%number2;

//show result

printf("Sum = %d",sum);

printf("\nSub = %d",sub);

printf("\nMult = %d",mult);

printf("\nDiv = %f",div);

printf("\nRemainder = %d\n",remainder);

system("PAUSE"); //delay

return 0;

}

**Output**