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 |
/*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();
}
Ask Question