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
Get step-by-step solutions from verified subject matter experts
