Computer Science, asked by sarasgana123456, 7 months ago

Create a calculator application using C programming language. List the operations Addition, Subtraction, Multiplication, Division, and Modulo, and based on users choice, get input operands from user and display the result. Display an option to either exit the flow, or continue to perform another operation. If user chooses to continue, display the list of operations again and proceed as given above

Answers

Answered by kunalhedaoo25
1

Answer:

#include <stdio.h>

int main() {

   char operator;

   double first, second;

   printf("Enter an operator (+, -, *,/): ");

   scanf("%c", &operator);

   printf("Enter two operands: ");

   scanf("%lf %lf", &first, &second);

   switch (operator) {

   case '+':

       printf("%.1lf + %.1lf = %.1lf", first, second, first + second);

       break;

   case '-':

       printf("%.1lf - %.1lf = %.1lf", first, second, first - second);

       break;

   case '*':

       printf("%.1lf * %.1lf = %.1lf", first, second, first * second);

       break;

   case '/':

       printf("%.1lf / %.1lf = %.1lf", first, second, first / second);

       break;

       // operator doesn't match any case constant

   default:

       printf("Error! operator is not correct");

   }

   return 0;

}

Similar questions