Challenge: Digital Clock

Lab C Beginner 10 points

Create int variables hours = 7, minutes = 5 and seconds = 9, and print them like a digital clock, with two digits each:

07:05:09

Input

None.

Output

07:05:09

Example

Output

07:05:09
Sample output available
Editor
C

Hints

%02d prints at least 2 digits, filling with a zero.

Use one printf with three placeholders.

Solution explanation

The 0 in %02d pads with zeros and the 2 is the width.

Show solution
#include <stdio.h>

int main() {
    int hours = 7;
    int minutes = 5;
    int seconds = 9;
    printf("%02d:%02d:%02d\n", hours, minutes, seconds);
    return 0;
}
Output
Answer
HOME LABS COMMUNITY DASHBOARD