diff --git a/C/README.md b/C/README.md index 2fb8a86b..8a0b269a 100644 --- a/C/README.md +++ b/C/README.md @@ -71,3 +71,4 @@ | Program-67 | Program to calulate all the prime between the range of numbers includes the numbers which is provided. | | Program-68 | Program to accept 0s and 1s as input and print if it consists 3 consecutive 0s | | Program-69 | Program to find strong number | +| Program-70 | Program to make a simple calculator | diff --git a/C/program-70/README.md b/C/program-70/README.md new file mode 100644 index 00000000..0b00a221 --- /dev/null +++ b/C/program-70/README.md @@ -0,0 +1,3 @@ +Program 70 + +C program to make simple calculator \ No newline at end of file diff --git a/C/program-70/program70.c b/C/program-70/program70.c new file mode 100644 index 00000000..8b90c5bf --- /dev/null +++ b/C/program-70/program70.c @@ -0,0 +1,38 @@ +#include + int main() + { + char op; + float number1,number2,result; + for(int i=0; i<5;i++) + { + printf("\nEnter\n + for Addition \n - for Subtraction \n * for Multiplication \n / for Division"); + printf("\nEnter the operation you want to perform\n"); + scanf("%s",&op); + printf("Enter two numbers\n"); + scanf("%f %f",&number1,&number2); + switch(op) + { + case'+':result=number1+number2; + printf("Sum is %f\n",result); + break; + case'-':result=number1-number2; + printf("Difference is %f\n",result); + break; + case'*':result=number1*number2; + printf("Product is %f\n",result); + break; + case'/':if(number2==0) + { + printf("Division not possible\n"); + } + else + { + result=number1/number2; + printf("Quotient is %f\n",result); + } + break; + default:printf("Enter proper input\n"); + } + } + return 0; + } \ No newline at end of file