#include<stdio.h>
#include<conio.h>
void main(){
float ans,a,b;
int choice;
while(1) {
Clrscr();
printf("Basic calculator\n 1.Addition\n 2.Subtraction\n 3.Multipication\n 4.Division\n 5.Exit\n Enter your choice\n");
scanf("%d",&choice);
printf("Enter two numbers\n");
scanf("%f%f",&a,&b);
switch (choice) {
case 1: ans=a+b; break;
case 2: ans=a-b; break;
case 3: ans=a*b; break;
case 4: if (b!=0) ans=a/b;
else printf("Value of b is not '0'\n Try Again!!");
break;
case 5: exit(0);
default: printf("Wrong input\n");
}
printf("answer is =%f\n",ans);
getch();
}
}
No comments:
Post a Comment