Question
Write a C program that uses only 1 scanf() statement and a while loop to do either of the following tasks: 1. Option 1 a.
Write a C program that uses only 1 scanf() statement and a while loop to do either of the following tasks:
1. Option 1 a. Display a prompt for a persons height in inches and first name. i. Include in the prompt the instruction to enter a q to quit the program.
b. Use a single scanf() statement in conjunction with a while loop to:
i. Read the persons height and first name. ii. Convert the height in inches to a height in feet and inches using / and % operators. 1. There are 12 inches in a foot, iii. Print out the persons name and height on 1 line.
1. Example output is: Nellies height is 5 foot 4 inches. c. Demonstrate that your program works by entering 2 sets of heights and names and then enter a q to exit the program.
2. Option 2 (Its similar to option 1 but has the order of the input changed.) a. Display a prompt for a persons first name and height in inches.
i. Include in the prompt the instruction to enter a q for the height to quit the program. b. Use a single scanf() statement in conjunction with a while loop to: i. Read the persons first name and height.
ii. Convert the height in inches to a height in feet and inches using / and % operators. 1. There are 12 inches in a foot, iii. Print out the persons name and height on 1 line.
1. Example output is: Franks height is 6 foot 1 inches. c. Demonstrate that your program works by entering 2 sets of names and heights and then enter a q q to exit the programthe first q is read in as a name.
Remember that the return value from scanf() is the number of items that it read. The returned value can be used as part of a comparison expression.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started