SOURCE CODE:
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b;
char choice;
float c;
clrscr();
printf("enter first number :");
scanf("%d",&a);
printf("enter second number :");
scanf("%d",&b);
printf("\nPRESS + for addition\n- for subtraction\n* for multiplication\n/ for division.");
printf("\n\nenter your choice :");
choice=getche();
switch(choice)
{
case '+':c=a+b;
printf("\nans is %f",c);
break;
case '-':c=a-b;
printf("\nans is %f",c);
break;
case '*':c=a*b;
printf("\nans is %f",c);
break;
case '/':c=(float)a/b;
printf("\nans is %f",c);
break;
default : printf("\ninvalid input");
}
getch();
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b;
char choice;
float c;
clrscr();
printf("enter first number :");
scanf("%d",&a);
printf("enter second number :");
scanf("%d",&b);
printf("\nPRESS + for addition\n- for subtraction\n* for multiplication\n/ for division.");
printf("\n\nenter your choice :");
choice=getche();
switch(choice)
{
case '+':c=a+b;
printf("\nans is %f",c);
break;
case '-':c=a-b;
printf("\nans is %f",c);
break;
case '*':c=a*b;
printf("\nans is %f",c);
break;
case '/':c=(float)a/b;
printf("\nans is %f",c);
break;
default : printf("\ninvalid input");
}
getch();
No comments :
Post a Comment