- Home
- Course Category
- Course Result
- Course Detail
Hot Line: 0124-2383121
Course Introduction
Includes
Certificate & Practice Material
Programs for practice
In the program below, we've introduced beginers to programming in C
Source Code: Program to implement switch case
# Program to implement switch case
#include<stdio.h>
#include<process.h>
#include<math.h>
void main()
{
float sub,sum,product,div,power,n1,n2;
int opt;
printf("Press the required option 1.Add 2.Sub 3.Multi 4.Divide 5.Power 6.Exit");
scanf("%d",&opt);
printf("Enter first integer:");
scanf("%f",&n1);
printf("Enter second integer:");
scanf("%f",&n2);
switch(opt){
case 1: sum=n1+n2;
printf("Sum of given numbers is:%.2f",sum);
break;
case 2: sub=n1-n2;
printf("sub of given number is:%.2f",sub);
break;
case 3: product=n1*n2;
printf("Product of given number is:%.2f",product);
break;
case 4: div=n1/n2;
printf("Quotient is:%.2f",div);
break;
case 5: power=pow(n1,n2);
printf("first number to the power second number is:%.2f",power);
break;
case 6: exit(0);
}
}
Output
Run the program to see the OUTPUT