#include <stdio.h>
#include <math.h>
#include <string.h>
int main()
{
char answer[10];
char dump;
printf("Welcome To Cli Calculator
Made by Argha Datta
");
do
{
char inputUser;
float num1, num2, result;
printf("Please enter your state of operation: ");
scanf("%c",&inputUser);
printf("Enter the first operand: ");
scanf("%f",&num1);
printf("Enter the second operand: ");
scanf("%f",&num2);
switch (inputUser)
{
case '+':
printf("The Addition of %f and %f is %f
",num1,num2,num1+num2);
break;
case '-':
printf("The Subtraction of %f and %f is %f
",num1,num2,num1-num2);
break;
case '*':
printf("The Multiplication of %f and %f is %f
",num1,num2,num1*num2);
break;
case '/':
printf("The Division of %f and %f is %f
",num1,num2,num1/num2);
break;
case '^':
printf("The Result of %f ^ %f is %f
",num1,num2,powf(num1,num2));
default:
printf("Invalid Operation,please try again!
");
break;
}
printf("Do you want to run it again(if yes ,type yes or type no for exit) :");
scanf("%s",answer);
dump = getchar();
} while (strcmp(answer,"yes") == 0);
return 0;
}
#include<stdio.h>
#include<conio.h>
void main()
{
char choice;
int a,b,res=0;
clrscr();
printf("Enter First value: ");
scanf("%d",&a);
printf("
Enter Operator: ");
choice=getch();
printf("
Enter Second value: ");
scanf("%d",&b);
switch(choice)
{
case '+':
res=a+b;
printf("Sum: %d",res);
break;
case '-':
res=a-b;
printf("Difference: %d",res);
break;
case '*':
res=a*b;
printf("Product: %d",res);
break;
case '/':
res=a/b;
printf("Quotient: %d",res);
break;
default:
printf("Enter Valid Operator!!");
}
getch();
}