Question: C programming practice problem. No NESTING LOOP OR ANYTHING, just simple Printf and Scanf calaculation. Write a program to read keyboard input to obtain your

C programming practice problem. No NESTING LOOP OR ANYTHING, just simple Printf and Scanf calaculation.

 C programming practice problem. No NESTING LOOP OR ANYTHING, just simple

Write a program to read keyboard input to obtain your name, the time going to bed, the time waking up, and the time duration sleep yesterday, and print them in a nice format as below. Note that bold faces indicate user keyboard input that are supposed to replace your own data. $ mysleep What is your first name? Alan What is your last name? Turing What time did you go to bed yesterday? 22 45 What time did you wake up this morning? 6 30 How long did you sleep? 7 45 Alan Turing You went to bed at 22: 45, and woke up at 6: 30. You slept for 7.75 hours. You need to declare string variables to store names. Refer the following snippet to handle strings. The detail of string handling will be covered in the lecture later. Char fname [64]: // to define a string variable for first name scanf("%s", fname): // to read a string from the keyboard. // No ampersand (&) required. printf("%s, fname): // to print a string to screen Challenge #1: to make the program to read a time in a format as "hh: mm" with a colon. Challenge #2: to compute the actual sleep time by calculating the difference between two times instead of user input

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!