#include <stdio.h>
#include <stdlib.h>
int main()
{
float a,b,s;
char d;
printf("choose an operation btwn + - * / : ");
scanf("%c",&d);
switch(d){
case '+' :
printf("enter two numbers ");
scanf("%f%f",&a,&b);
s = a + b ;
printf("%.1f + %.1f = %.1f",a,b,s);
break;
case '-' :
printf("enter two numbers ");
scanf("%f%f",&a,&b);
s = a - b ;
printf("%.1f - %.1f = %.1f",a,b,s);
break;
case '*' :
printf("enter two numbers ");
scanf("%f%f",&a,&b);
s = a * b ;
printf("%.1f * %.1f = %f",a,b,s);
break;
case '/' :
printf("enter two numbers ");
scanf("%f%f",&a,&b);
s = a / b ;
printf("%.1f / %.1f = %.1f",a,b,s);
break;
default :
printf("enter a valid operation !");
break;
}
return 0;
}
#include<stdio.h>
#include<conio.h>
void main()
{
int num1,num2,opt;
clrscr();
printf("Enter the first Integer:
");
scanf("%d",&num1);
printf("Enter the second Integer:
");
scanf("%d",&num2);
for(;;)
{
printf("
Enter the your option:
");
printf("1-Addition.
2-Substraction.
3-Multiplication.
4-Division.
5-Exit.
");
scanf("%d",&opt);
switch(opt)
{
case 1:printf("
Addition of %d and %d is: %d",num1,num2,num1+num2);
break;
case 2:printf("
Substraction of %d and %d is: %d",num1,num2,num1-num2);
break;
case 3:printf("
Multiplication of %d and %d is: %d",num1,num2,num1*num2);
break;
case 4:
if(num2==0)
{
printf("OOps Devide by zero
");
}
else
{
printf("
Division of %d and %d is: %d",num1,num2,num1/num2);
}
break;
case 5: return 0;
break;
default:printf("
Enter correct option
");
break;
}
}
getch();
}