Write a program to accept 2 nos.& display their Addition, Subtraction, Division, Multiplication.
--->
#include<stdio.h>
#include<conio.h>
void main()
{
int c;
float a,b;
float r;
clrscr();
printf("1. Add\n");
printf("2. Subtract\n");
printf("3. Division\n");
printf("4. Multiply\n");
printf("Enter your choice...");
scanf("%d",&c);
printf("Enter 2 Nos.");
scanf("%f%f",&a,&b);
switch(c)
{
case 1:
{
r=a+b;
break;
}
case 2:
{
r=a-b;
break;
}
case 3:
{
r=a/b;
break;
}
case 4:
{
r=a*b;
break;
}
default:
{
printf("Invalid Entry.");
}
}
printf("Result is %5.2f",r);
getch();
}
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment