/*Write a C program, which takes two integer operands and one operator from the user, performs the operation and then prints the result. (Consider the operators +,-,*, /, % and use Switch Statement)*/
#include<stdio.h>
#include<conio.h>
#include<math.h>
main()
{
int a,b,c;
int ch;
printf("\n Enter the a value");
scanf("%d",&a);
printf("\n Enter the b value");
scanf("%d",&b);
prinrf("\n*************MENU***************");
printf("\n1.Addition \n2.Substraction \n3.Multiplication \n4.Division \n5.Modulo \n6.Exit");
scanf("%d",&ch);
switch(ch)
{
case 1: c=a+b;
printf("\nThe addition of two numbers is:%d",c);
break;
case 2: c=a-b;
printf("\nThe substraction of two numbers is:%d",c);
break;
case 3:c=a*b;
printf("\nThe multiplication of two numbers is:%d",c);
break;
case 4:c=a/b;
printf("\n The division of two numbers is:%d",c);
break;
case 5:c=a%b;
printf("\n The remainder for division of %d divided by %d is:%d"a,b,c);
break;
case 6:printf("\nTermination by choice");
break;
default:printf("\nPlease enter a valid choice");
break;
}
getch();
}
#include<stdio.h>
#include<conio.h>
#include<math.h>
main()
{
int a,b,c;
int ch;
printf("\n Enter the a value");
scanf("%d",&a);
printf("\n Enter the b value");
scanf("%d",&b);
prinrf("\n*************MENU***************");
printf("\n1.Addition \n2.Substraction \n3.Multiplication \n4.Division \n5.Modulo \n6.Exit");
scanf("%d",&ch);
switch(ch)
{
case 1: c=a+b;
printf("\nThe addition of two numbers is:%d",c);
break;
case 2: c=a-b;
printf("\nThe substraction of two numbers is:%d",c);
break;
case 3:c=a*b;
printf("\nThe multiplication of two numbers is:%d",c);
break;
case 4:c=a/b;
printf("\n The division of two numbers is:%d",c);
break;
case 5:c=a%b;
printf("\n The remainder for division of %d divided by %d is:%d"a,b,c);
break;
case 6:printf("\nTermination by choice");
break;
default:printf("\nPlease enter a valid choice");
break;
}
getch();
}
No comments:
Post a Comment