#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Posts
    4
    Rep Power
    0

    24-hour time then display time in 12-hour form


    can someone help me get through this program
    Enter a 24-hour time:21:11
    Equivalent 12-hour time:9:11 pm
    becareful not to display 12:00 as 0:00

    this is how I did it but it did not work
    #include <stdio.h>

    main ()
    {
    12-hour time,24-hour time;
    printf("Enter 24-hour time: ");
    scanf("%f",&24hour time)
    if (21:11==9:11)
    else
    printf("21:11!=9:11);
    return 0;
    }


    please help this is c language program
    thanks
  2. #2
  3. Contributing User
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jan 2003
    Location
    USA
    Posts
    7,253
    Rep Power
    2222
    I don't think you're even trying. If you're going to post code at the very least it should be something that might have a chance of compiling. What you've written doesn't even make any sense.

    And use code tags!

    Just think of what it takes to convert normal time to that 12-hour nonsense. You're going to read in the time, parse out the hours, and then depending on its value you'll figure out whether it is ante meridian or post meridian and create your output accordingly. The only coding structure you should need would be if-then-else. Real simple.

IMN logo majestic logo threadwatch logo seochat tools logo