
Concept explainers
C program
The program will prompt the user to choose the operation choice (from 1 to 4). Then it asks the user to input two integer vales for the calculation. See the sample below.
MENU
1. Add
2. Subtract
3. Multiply
4. Divide
Enter your choice: 1
Enter your two numbers: 12 15
Result: 27
Continue? y
The program also asks the user to decide whether he/she wants to continue the operation. If he/she input ‘y’, the program will prompt the user to choose the operation again. Instead, the program will terminate.
The program must use a separate function for each mathematical operation.
(Do not use printf or scanf inside the function ... all input/output should be in main)

Introduction
In C, the switch statement is an alternative to the if-else-if ladder statement that enables us to do several operations for the various potential values of a single variable called the switch variable. Here, we can define different statements in a variety of situations for varied values of a single variable.
Step by stepSolved in 4 steps with 3 images

- Even though the EXIT clause can be used in any type of loop, it is considered good form to use the EXIT clause only in basic loops. Answers: Yes Noarrow_forwardC programming: 11. Which type(s) of loop (for/do-while/while) would you use in each of the following situations? a)Asking the user if the program has guessed their number or not. b)Printing the name of each of the 36 students in the class. c)Asking the user for an unknown number of class grades. d)Counting how many times it takes the user toguess the program’s number. 12. How are the loops controlled (event or counter) in the following situations? a)Asking the user if the song is over. b)Counting how many times it takes the user to guess the program’s number. c)Asking the user to enter all 6 of their classwork grades to date. d)Printing the 16 steps of the Cupid Shuffle.arrow_forwardChapter 4 Loops and Files 17. Random Number Guessing Game Write a program that generates a random number and asks the user to guess what the num- ber is. If the user's guess is higher than the random number, the program should display "Too high, try again." If the user's guess is lower than the random number, the program should display "Too low, try again." The program should use a loop that repeats until the user cor rectly guesses the random number.arrow_forward
- Which of the following can you nest within one another? A. for loop within an if statement B. while loop within a for loop C. if statement in a for loop D. for loop within a for looparrow_forwardDesign a program that uses nested loops to collect data and calculate the average rainfall over a period of years. The program should first ask for the number of years. The outer loop will iterate once for each year. The inner loop will iterate twelve times, once for each month. Each iteration of the inner loop will ask the user for the inches of rainfall for that month. After all iterations, the program should display the number of months, the total inches of rainfall, and the average rainfall per month for the entire period. Modularize the program. Present clear formatted code with comments. I need this coded in pseudocode, please.arrow_forwardprogram4_2.pyWrite a program that uses a while loop to enable the user to enter any number of positive integers. The loop should end when a sentinel value of 0 (zero) is entered. The program should then report the sum of the even integers and the sum of the odd integers.arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education





