a) What does this program do? Hint: Write a simple description for the tasks this program perform. eg. The program prompts the user to enter and it computes and prints .. b) Show a sample output for the program c) What will happen if we delete break statements that is shown at the end of case clauses. Hint: Run the program without break and see the output. Look at the notes in Slide #40 of Lec-3. Page 2 of 7 d) Rewrite the pro using if.else structure instead of switch-case statement:

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
a) What does this program do?
Hint: Write a simple description for the tasks this program perform.
eg., The program prompts the user to enter . and it computes and prints .. ..... .
b) Show a sample output for the program
c) What will happen if we delete break statements that is shown at the end of case clauses.
Hint: Run the program without break and see the output. Look at the notes in Slide #40 of Lec-3.
Page 2 of 7
d) Rewrite the program using if..else structure instead of switch-case statement:
Transcribed Image Text:a) What does this program do? Hint: Write a simple description for the tasks this program perform. eg., The program prompts the user to enter . and it computes and prints .. ..... . b) Show a sample output for the program c) What will happen if we delete break statements that is shown at the end of case clauses. Hint: Run the program without break and see the output. Look at the notes in Slide #40 of Lec-3. Page 2 of 7 d) Rewrite the program using if..else structure instead of switch-case statement:
Question #1
Study the following C program and answer the below questions
Hint: you might run it in Dev C++ before starting answering the questions!
#include<stdio.h>
int main(void) {
int number;
char choice;
printf("Please enter an integer number: " ) ;
scanf("%d" , &number);
printf("\nTo check whether the number is even or odd, press e \n");
printf("To check whether the number is positive or negative, press p \n");
printf("To check whether the number is multiple of 10, press m \n");
printf("\nPlease enter your choice: ");
scanf(" %c" , &choice);
switch(choice) {
case 'e':
case 'E':
if (number % 2 == 0){
printf("\n%d is even \n" , number);
else {
printf("\n%d is odd \n" , number);
}
break;
case 'p':
case 'P':
if (number > 0){
printf("\n%d is positive \n" , number);
else if (number < 0){
printf("\n%d is negative \n" , number);
else {
printf("\n%d is zero! \n" , number);
break;
case 'm':
case 'M':
if (number % 10 == 0){
printf("\n%d is a multiple of 10
' , number);
}
else {
printf("\n%d is NOT a multiple of 10 \n", number);
break;
default:
printf("\NERROR: %c is unrecognized option!!! \n" , choice);
return 0;
}
Page 1 of 7
Transcribed Image Text:Question #1 Study the following C program and answer the below questions Hint: you might run it in Dev C++ before starting answering the questions! #include<stdio.h> int main(void) { int number; char choice; printf("Please enter an integer number: " ) ; scanf("%d" , &number); printf("\nTo check whether the number is even or odd, press e \n"); printf("To check whether the number is positive or negative, press p \n"); printf("To check whether the number is multiple of 10, press m \n"); printf("\nPlease enter your choice: "); scanf(" %c" , &choice); switch(choice) { case 'e': case 'E': if (number % 2 == 0){ printf("\n%d is even \n" , number); else { printf("\n%d is odd \n" , number); } break; case 'p': case 'P': if (number > 0){ printf("\n%d is positive \n" , number); else if (number < 0){ printf("\n%d is negative \n" , number); else { printf("\n%d is zero! \n" , number); break; case 'm': case 'M': if (number % 10 == 0){ printf("\n%d is a multiple of 10 ' , number); } else { printf("\n%d is NOT a multiple of 10 \n", number); break; default: printf("\NERROR: %c is unrecognized option!!! \n" , choice); return 0; } Page 1 of 7
Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY