Question: C PROGRAMMING Write a program that asks the user for a number between 1 and 20. The program will then display the powers of 2
C PROGRAMMING
Write a program that asks the user for a number between 1 and 20. The program will then display the powers of 2 up to the number entered. If the number entered is not between 1 and 20, inform the user and re-ask for the number until a number in the range of 1 through 20 is entered.
This program will require a loop (use a while loop) to validate the number entered, and will also require a loop (use a for loop) for the powers of two.
Example Run #1: (bold type is what is entered by the user)
Enter an integer (between 1 and 20): 5
2^1 = x 2^2 = x 2^3 = x 2^4 = xx 2^5 = xx
Example Run #2:
Enter an integer (between 1 and 20): 25 The integer entered, 25, is not in the range of 1 to 20. Please re-enter the integer: 5
2^1 = x 2^2 = x 2^3 = x 2^4 = xx 2^5 = xx
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
