Starting Vocational Training From 1-May-2024 Get Detail
Menu driven program for addition,substraction,multiplication and division.
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
add(int x,int y)
{
int z;
z=x+y;
printf("
Sum is %d",z);
}
sub(int x,int y)
{
int z;
z=x-y;
printf("
Substraction is %d",z);
}
mul(int x,int y)
{
int z;
z=x*y;
printf("
Multiplication is %d",z);
}
division(int x,int y)
{
int z;
z=x/y;
printf("
Division is %d",z);
}
menu()
{
printf("
1.Addition");
printf("
2.Substraction");
printf("
3.Multiplication");
printf("
4.Division");
printf("
5.Exit");
}
void main()
{
int ch,a,b;
clrscr();
while(1)
{
menu();
printf("
Enter your choice");
scanf("%d",&ch);
if(ch==5)
{
exit(0);
}
else if(ch<=4)
{
printf("Enter two value");
scanf("%d%d",&a,&b);
switch(ch)
{
case 1:
add(a,b);
break;
case 2:
sub(a,b);
break;
case 3:
mul(a,b);
break;
case 4:
division(a,b);
break;
}
}
else
printf("Invalid choice");
}
getch();
}