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
Post a Comment