Write a simple C code with printf or scanf statement for each of the following


a. Print the unsigned integer 3500 left justified in a 10-digit field with 6 digits. b. Print 1.234 in a 9-digit field with five digits after the decimal point. c. Read a time in the form hh:mm:ss, storing the parts of the time in the integer variables hour, minute and second. Skip the colons (:) in the input stream. Enter a time in hh:mm:ss format: 12:35:68 Print the below message using the variables accepted in step c: Hour: 12 Minute: 35 Second: 68



#include <stdio.h>
int main(void) {
char t[8];
int hour, minute, second;
printf("Enter time in HH:MM:SS format: ");
// TAKING user input and skipping colons
scanf("%d:%d:%d",&hour, &minute, &second);
// printing output
printf("Hour: %d\n",hour);
printf("Minute: %d\n",minute);
printf("Second: %d\n",second);
return 0;
}
/*OUTPUT
Enter time in HH:MM:SS format: 12:35:68
Hour: 12
Minute: 35
Second: 68
*/

Comments