C

Arithmetic Operators

C supports all the basic arithmetic operators. The following table shows all the basic arithmetic operators.

Operator Description
+ adds two operands
- subtract second operands from first
* multiply two operand
/ divide numerator by denominator
% remainder of division
++ Increment operator increases integer value by one
-- Decrement operator decreases integer value by one

Example:

/*Write a C Program Which Find Addition, Subtraction, Multiplication And Division Of Two Numbers.*/
#include<stdio.h>
#include<conio.h>
void main()
{
    int n1,n2,add,sub,mul,div,mod;
    clrscr();
    printf("Enter Value of N1 = ");
    scanf("%d",&n1);

    printf("Enter Value of N2 = ");
    scanf("%d",&n2);

    add=n1+n2;
    printf("\n%d + %d = %d \t Addition",n1,n2,add);

    sub=n1-n2;
    printf("\n%d - %d = %d \t Subtraction",n1,n2,sub);

    mul=n1*n2;
    printf("\n%d * %d = %d \t Multiplication",n1,n2,mul);

    div=n1/n2;
    printf("\n%d / %d = %d \t Division",n1,n2,div);

    mod=n1%n2;
    printf("\n%d %% %d = %d \t remainder of Division",n1,n2,mod);
    getch();
}

Output:

Command Prompt
Enter Value of N1 = 10
Enter Value of N2 = 5
10 + 5 = 15        Addition
10 - 5 = 5         Subtraction
10 * 5 = 50        Multiplication
10 / 5 = 2         Division
10 % 5 = 0         remainder of Division



Subscribe us on Youtube

Share This Page on


Ask Question