Question: a) Write a program that asks for a number. Then the program should print 1 through the given number on separate lines. b) Encapsulate your

a) Write a program that asks for a number. Then the program should print 1 through the given number on separate lines.

b) Encapsulate your code in a while-loop that asks the user if he/she would like to run the program again. Note that when reading a character from the input stream, the newline from the previous input is still buffered and considered as input. To discard the newline, start the scanf string with a space like this: scanf(" %c", &input);

Give a number: 5

1

2

3

4

5

Run again (y/n)? Y

Give a number: 2

1

2

Run again (y/n)? n

Exiting... [.../exercise]$

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!