- Define a function named procedure1() that will be called from main() function, the function will: 1. Use a do-while loop, to prompt the user input an integer and add all the values entered. Keep on doing this until an invalid value that is smaller than -9999 or bigger than 9999 is entered, then printout the sum of all the values entered. 2. You can use break statement to exit the looping process when an invalid data (>9999 or <-9999) is received. 3. Example: Enter a number between -9999 to 9999: 93 between -9999 to 9999: 90 Enter a number Enter a number between -9999 to 9999: 129 Enter a number between -9999 to 9999: -300 Enter a number between -9999 to 9999: 983 Enter a number between -9999 to 9999: 9378 Enter a number between -9999 to 9999: 972 Enter a number between -9999 to 9999: 10000 The sum of all the inputs is: 11345 4. Please use your program to input at least 8 valid numbers as the test case.
Types of Loop
Loops are the elements of programming in which a part of code is repeated a particular number of times. Loop executes the series of statements many times till the conditional statement becomes false.
Loops
Any task which is repeated more than one time is called a loop. Basically, loops can be divided into three types as while, do-while and for loop. There are so many programming languages like C, C++, JAVA, PYTHON, and many more where looping statements can be used for repetitive execution.
While Loop
Loop is a feature in the programming language. It helps us to execute a set of instructions regularly. The block of code executes until some conditions provided within that Loop are true.
C
Step by step
Solved in 3 steps with 1 images