Define a function named procedure2() that will be called from main() function, the function will: 1. Use the switch statement and infinite loop to generate the following menu and ask the user to choose one of the options from the menu (show the menu to the user). 1 - Work on Negative values 2 Work on A Pattern 3 4 Print A Message Exit the program Please select your option: 2. If the user selects 1: a. the program will ask the user to enter a negative value, which is an integer N. If the number is negative, the sum of all numbers between -1 and N is displayed on the screen. For example, if the input n = -7, the program shou print the following output: The option 1 result is: -1 -2 -3 -4 -5 -6 -7 = -28 b. If the input number is positive, the program should print out "the input is invalid, please try to input another number" and ask for another number to repeat this process until the input number is a negative number. c. After the exection of this part of the program, the program will display the menu again and wait for the next option. 3. If the user selects option 2: a. the program should ask the user for an integer value M, which is between 2 to 60, and then print the following pattern with many asterisks. The following example is when the input M is 6: It will print 11 lines of asterisks that include 1 to 6 asterisks each row, and then 5 to 1 asteriskes each row. **** Menu ***** ****** ***** **** *** ** b. The program should use for loop to create the pattern. If the input is not in the range from 2 to 60, your program should print out "the input is invalid, please try to input another number" and ask for another number M until the given number is between 2 and 60. c. After the exection of this part of the program, the program will display the menu again and wait for the next option. 4. If the user selects option 3, the program should print your name as the following: Hi, welcome! The program is made by YOUR_NAME_HERE. 5. The program will exit the program when the input is 4. Please notice that this is the ONLY exit condition for the program. 6. Test your program with at least 4 different cases with the selection of 1, 2, 3 and 4 as the menu options, respectively. Please submit the screenshots of all these test cases.
Operations
In mathematics and computer science, an operation is an event that is carried out to satisfy a given task. Basic operations of a computer system are input, processing, output, storage, and control.
Basic Operators
An operator is a symbol that indicates an operation to be performed. We are familiar with operators in mathematics; operators used in computer programming are—in many ways—similar to mathematical operators.
Division Operator
We all learnt about division—and the division operator—in school. You probably know of both these symbols as representing division:
Modulus Operator
Modulus can be represented either as (mod or modulo) in computing operation. Modulus comes under arithmetic operations. Any number or variable which produces absolute value is modulus functionality. Magnitude of any function is totally changed by modulo operator as it changes even negative value to positive.
Operators
In the realm of programming, operators refer to the symbols that perform some function. They are tasked with instructing the compiler on the type of action that needs to be performed on the values passed as operands. Operators can be used in mathematical formulas and equations. In programming languages like Python, C, and Java, a variety of operators are defined.
C
Step by step
Solved in 4 steps with 2 images