Search This Blog

C Program Perform Arithmetic Operations Using SwitchCase

C Program Perform Arithmetic Operations Using Switch Case :
//C Program Perform Arithmetic Operations Using SwitchCase

#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
void main()
{
int ch;
float a,b,res;
clrscr();
printf("\n Enter I numbers:- ");
scanf("%f",&a);
printf("\n Enter II numbers:- ");
scanf("%f",&b);
printf("\n Menu\n 1.Addition\n 2.Subtraction\n 3.Multiplication\n 4.Division\n");
printf("\n Enter your choice:- ");
scanf("%d",&ch);
switch(ch)
{
case 1: res=a+b;
break;
case 2: res=a-b;
break;
case 3: res=a*b;
break;
case 4: res=a/b;
break;
default: printf("\n Wrong choice!!nPress any key… ");
getch();
exit(0);
}
printf("\n Result= %f",res);
getch();
}
OUTPUT
C Program Perform Arithmetic Operations Using SwitchCase

No comments:

Post a Comment