C program to demonstrate the use of all arithmetic operators.

Program:

#include<stdio.h>

#include<conio.h>


void main()

{

    int a,b,c;

    clrscr();

    printf("a = ");

    scanf("%d",&a);

    printf("b = ");

    scanf("%d",&b);

    c=a+b;

    printf("%d + %d = %d //Addition\n",a,b,c);

    c=a-b;

    printf("%d - %d = %d //Substraction\n",a,b,c);

    c=a*b;

    printf("%d * %d = %d //Multiplication\n",a,b,c);

    c=a/b;

    printf("%d / %d = %d //Division\n",a,b,c);

    c=a%b;

    printf("%d %% %d = %d //Modulus\n",a,b,c);

    getch();

}


Output:

a = 5

b = 2

5 + 2 = 7 //Addition

5 - 2 = 3 //Substraction

5 * 2 = 10 //Multiplication

5 / 2 = 2 //Division

5 % 2 = 1 //Modulus

Comments

Popular posts from this blog

C program to read and display book information using structure

Count positive, negative and zero values in an array

Maximum value from array