Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

Been tasked to make a simple calculator. I think there is a problem and I don't know what. Can you help?

+1 vote
asked Sep 24, 2018 by Earl John Almocera (130 points)
here's my code :^)

https://onlinegdb.com/H1ejTVItQ

1 Answer

0 votes
answered Sep 24, 2018 by femrost
#include<stdio.h>

int

main ()

{

  int num1, num2, choice;

  do

    {

      printf

("\nMenu:\n [1] Addition\n [2] Subtraction\n [3] Multiplication\n [4] Division\n [0] Exit\n\nPlease pick an option:");

      scanf ("%d", &choice);

      if (choice == 0)

break;

      printf ("\nInput two numbers to solve:");

      scanf ("%d%d", &num1, &num2);

      switch (choice)

{

case 1:

  printf ("%d + %d = %d", num1, num2, num1 + num2);

  break;

case 2:

  printf ("%d - %d = %d", num1, num2, num1 - num2);

  break;

case 3:

  printf ("%d x %d = %d", num1, num2, num1 * num2);

  break;

case 4:

  printf ("%d รท %d = %.1f", num1, num2, (float) num1 / num2);

  break;

default:

  printf ("\nInvalid option input...\nPlease try again.\n");

}

    }

  while (choice);

  return 0;

}

 here you go in line 26 you were adding not multiplying
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...