//WAP to find sum,difference, and product of two numbers using switch.
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
int choice;
int a,b,output;
printf("please enter your two numbers for a and b for operation\n");
scanf("%d%d",&a,&b);
printf("'now,we have following menu\n");
printf( "1.to get sum\n");
printf("2. to get difference\n");
printf("3 to get product\n");
printf(" any other number to exit");
printf("enter your choice 1 or 2 or 3 or any other number\n");
scanf("%d",&choice);
switch(choice)
{
case 1:
printf("we are going to get sum\n");
printf("the sum=%d",a+b);
break;
case 2:
printf("we are going to get difference \n");
printf("the difference=%d",a-b);
break;
case 3:
printf("we are going to get product,\n");
printf("the product=%d",a*b);
break;
default:
printf("sorry, not a valid input\n");
printf("thank u, terminating....\n");
}
getch();
}
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
int choice;
int a,b,output;
printf("please enter your two numbers for a and b for operation\n");
scanf("%d%d",&a,&b);
printf("'now,we have following menu\n");
printf( "1.to get sum\n");
printf("2. to get difference\n");
printf("3 to get product\n");
printf(" any other number to exit");
printf("enter your choice 1 or 2 or 3 or any other number\n");
scanf("%d",&choice);
switch(choice)
{
case 1:
printf("we are going to get sum\n");
printf("the sum=%d",a+b);
break;
case 2:
printf("we are going to get difference \n");
printf("the difference=%d",a-b);
break;
case 3:
printf("we are going to get product,\n");
printf("the product=%d",a*b);
break;
default:
printf("sorry, not a valid input\n");
printf("thank u, terminating....\n");
}
getch();
}
No comments:
Post a Comment