#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
void main()
{
clrscr();
float a, b, result;
char choice, ch;
do
{
printf("1.Addition\n");
printf("2.Subtraction\n");
printf("3.Multiplication\n");
printf("4.Division\n");
printf("5.Exit\n\n");
printf("Enter Your Choice : ");
scanf("%c",&choice);
switch(choice)
{
case '1' : printf("Enter two number : ");
scanf("%f%f",&a,&b);
result=a+b;
printf("Result = %f",result);
break;
case '2' : printf("Enter two number : ");
scanf("%f%f",&a,&b);
result=a-b;
printf("Result = %f",result);
break;
case '3' : printf("Enter two number : ");
scanf("%f%f",&a,&b);
result=a*b;
printf("Result = %f",result);
break;
case '4' : printf("Enter two number : ");
scanf("%f%f",&a,&b);
result=a/b;
printf("Result = %f",result);
break;
case '5' : exit(0);
break;
default : printf("Wrong Choice..!!");
break;
}
printf("\n------------------------------------\n");
}while(choice!=5 && choice!=getchar());
getch();
}
Run:
Previous Next
#include<conio.h>
#include<stdlib.h>
void main()
{
clrscr();
float a, b, result;
char choice, ch;
do
{
printf("1.Addition\n");
printf("2.Subtraction\n");
printf("3.Multiplication\n");
printf("4.Division\n");
printf("5.Exit\n\n");
printf("Enter Your Choice : ");
scanf("%c",&choice);
switch(choice)
{
case '1' : printf("Enter two number : ");
scanf("%f%f",&a,&b);
result=a+b;
printf("Result = %f",result);
break;
case '2' : printf("Enter two number : ");
scanf("%f%f",&a,&b);
result=a-b;
printf("Result = %f",result);
break;
case '3' : printf("Enter two number : ");
scanf("%f%f",&a,&b);
result=a*b;
printf("Result = %f",result);
break;
case '4' : printf("Enter two number : ");
scanf("%f%f",&a,&b);
result=a/b;
printf("Result = %f",result);
break;
case '5' : exit(0);
break;
default : printf("Wrong Choice..!!");
break;
}
printf("\n------------------------------------\n");
}while(choice!=5 && choice!=getchar());
getch();
}
Run:
Previous Next
No comments:
Post a Comment