Question: Compile, debug (find and fix any syntax errors), and execute the program and fix any semantic errors: /* This C program demonstrates the switch statement
Compile, debug (find and fix any syntax errors), and execute the program and fix any semantic errors:

/* This C program demonstrates the switch statement without using breaks. */
/* The program is tested on MS Visual C++ platform */
#include
#pragma warning(disable : 4996)
void main() {
char ch;
ch = '+';
int f, a = 10, b = 20;
printf("ch = %c ", ch);
switch (ch) {
case '+': f = a + b; printf("f = %d ", f);
case '-': f = a - b; printf("f = %d ", f);
case '*': f = a * b; printf("f = %d ", f);
case '/': f = a / b; printf("f = %d ", f);
default: printf("invalid operator ");
}
ch = '-';
printf("ch = %c ", ch);
switch (ch) {
case '+': f = a + b; printf("f = %d ", f);
case '-': f = a - b; printf("f = %d ", f);
case '*': f = a * b; printf("f = %d ", f);
case '/': f = a / b; printf("f = %d ", f);
default: printf("invalid operator ");
}
ch = '*';
printf("ch = %c ", ch);
switch (ch) {
case '+': f = a + b; printf("f = %d ", f);
case '-': f = a - b; printf("f = %d ", f);
case '*': f = a * b; printf("f = %d ", f);
case '/': f = a / b; printf("f = %d ", f);
default: printf("invalid operator ");
}
ch = '/';
printf("ch = %c ", ch);
switch (ch) {
case '+': f = a + b; printf("f = %d ", f);
case '-': f = a - b; printf("f = %d ", f);
case '*': f = a * b; printf("f = %d ", f);
case '/': f = a / b; printf("f = %d ", f);
default: printf("invalid operator ");
}
ch = '%';
printf("ch = %c ", ch);
switch (ch) {
case '+': f = a + b; printf("f = %d ", f);
case '-': f = a - b; printf("f = %d ", f);
case '*': f = a * b; printf("f = %d ", f);
case '/': f = a / b; printf("f = %d ", f);
default: printf("invalid operator ");
}
}
Expected Output:

RTTY 2.1 Use GCC onGeneral Server and a text editor to enter the program (the code is given on the next page). Compile, debug (find and fix any syntax errors), and execute the program and fix any semantic errors, for example, by adding "break" statements in the required places and by fixing incorrect characters copied into the programming environment, if any, and by type changing to print a floating point number. The code is supposed to perform one of the operations in each switch case. Submit the 10 points] corrected program
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
