Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Need help in the calculator What do I need to fix #include #include main() { int

ID: 441617 • Letter: N

Question

Need help in the calculator What do I need to fix #include #include main() { int number1, number2, choice5; printf("Welcome to Simple Calculator "); printf("[1] Addition "); printf("[2] Subtraction "); printf("[3] Multiplication "); printf("[4] Division "); scanf("%d", &choice5); if (choice5 == 1); { printf("You have chosen Addition, Please enter the two numbers you wish to add "); scanf("%d", &number1); scanf("%d", &number2); printf("Sum is %d ", number1 + number2); } if (choice5 == 2); { printf("You have chosen Subtraction, Please enter the two numbers you wish to subtract "); scanf("%d", &number1); scanf("%d", &number2); printf("Sum is %d ", number1 - number2); } if (choice5 == 3); { printf("You have chosen Multiplication, Please enter the two numbers you wish to multiply "); scanf("%d", &number1); scanf("%d", &number2); printf("Sum is %d ", number1 * number2); } if (choice5 == 4); { printf("You have chosen Division, Please enter the two numbers you wish to divide "); scanf("%d", &number1); scanf("%d", &number2); printf("Sum is %d ", number1 / number2); } return 0; }

Explanation / Answer

/*** your code modified **/

//the problem is after if statement and before "{" you put a ";" which should not be there...

#include <stdio.h> //include stdio.h while compiling
int main() {
int number1, number2, choice5;
printf("Welcome to Simple Calculator ");
printf("[1] Addition ");
printf("[2] Subtraction ");
printf("[3] Multiplication ");
printf("[4] Division ");
scanf("%d", &choice5);
if (choice5 == 1) {
printf("You have chosen Addition, Please enter the two numbers you wish to add ");
scanf("%d", &number1); scanf("%d", &number2);
printf("Sum is %d ", number1 + number2); }
else if (choice5 == 2) {
printf("You have chosen Subtraction, Please enter the two numbers you wish to subtract ");
scanf("%d", &number1); scanf("%d", &number2);
printf("Difference is %d ", number1 - number2); }
else if (choice5 == 3) {
printf("You have chosen Multiplication, Please enter the two numbers you wish to multiply ");
scanf("%d", &number1); scanf("%d", &number2);
printf("Product is %d ", number1 * number2); }
else if (choice5 == 4){
printf("You have chosen Division, Please enter the two numbers you wish to divide ");
scanf("%d", &number1); scanf("%d", &number2);
printf("Quotient is %d ", number1 / number2); }
return 0; }

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote