/* Program in C to find sum, difference and product of 2 numbers using switch case statement */
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,ch;
printf("\n Enter First Number :");
scanf("%d",&a);
printf("\n Enter Second Number :");
scanf("%d",&b);
printf("\n Enter Your Choice: ( 1. Sum: 2. Difference : 3. Product: ) ");
scanf("%d",&ch);
switch (ch)
{
case 1:
{
printf("\n The sum = %d",a+b);
break;
}
case 2:
{
printf("\n The difference = %d",a-b);
break;
}
case 3:
{
printf("\n The Product = %d",a*b);
break;
}
default:
{
printf("\n out of range");
}
}
getch();
}
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,ch;
printf("\n Enter First Number :");
scanf("%d",&a);
printf("\n Enter Second Number :");
scanf("%d",&b);
printf("\n Enter Your Choice: ( 1. Sum: 2. Difference : 3. Product: ) ");
scanf("%d",&ch);
switch (ch)
{
case 1:
{
printf("\n The sum = %d",a+b);
break;
}
case 2:
{
printf("\n The difference = %d",a-b);
break;
}
case 3:
{
printf("\n The Product = %d",a*b);
break;
}
default:
{
printf("\n out of range");
}
}
getch();
}
0 comments:
Post a Comment