Write a C program to enter two numbers and perform all arithmetic operations.
Static Program
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int a=15, b=13,sum,sub,mul,div,mod;
sum =a+b;
sub = a-b;
mul = a*b;
div = a/b;
mod = a%b;
printf("\nThe sum of 2 number is :- %d",sum);
printf("\nThe sub of 2 number is :- %d",sub);
printf("\nThe mul of 2 number is :- %d",mul);
printf("\nThe div of 2 number is :- %d",div);
printf("\nThe mod of 2 number is :- %d",mod);
getch();
}
Output :-
Dynamic Program
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int a,b,sum,sub,mul,div,mod;
printf("Enter the first number :-");
scanf("%d",&a);
printf("Enter thr second number :-");
scanf("%d",&b);
sum = a+b;
sub = a-b;
mul = a*b;
div = a/b;
mod = a%b;
printf("\nThe sum of 2 number is :- %d",sum);
printf("\nThe sub of 2 number is :- %d",sub);
printf("\nThe mul of 2 number is :- %d",mul);
printf("\nThe div of 2 number is :- %d",div);
printf("\nThe mod of 2 number is :- %d",mod);
getch();
}
Output :-