Question: ( Validating User Input ) Modify the program in Figure 3 . 6 to validate its inputs. For each input, if the value is other

(Validating User Input) Modify the program in Figure 3.6 to validate its inputs.
For each input, if the value is other than 1 or 2, keep looping until the user enters
a correct value. Write sWrite single C statements to perform each of the following tasks:
a) Input integer variable x with scanf. Use the conversion specification %d.
b) Input integer variable y with scanf. Use the conversion specification %d.
c) Set integer variable i to 1.
d) Set integer variable power to 1.
e) Multiply integer variable power by x and assign the result to power.
f) Increment variable i by 1.
g) Test i to see if its less than or equal to y in the condition of a while statement.
h) Output integer variable power with printf.ingle C statements to perform each of the following tasks:
a) Input integer variable x with scanf. Use the conversion specification %d.
b) Input integer variable y with scanf. Use the conversion specification %d.
c) Set integer variable i to 1.
d) Set integer variable power to 1.
e) Multiply integer variable power by x and assign the result to power.
f) Increment variable i by 1.
g) Test i to see if its less than or equal to y in the condition of a while statement.
h) Output integer variable power with printf.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!