C Program - Accept the time as hour, minute and seconds and check whether the time is valid. C


Program

#include <stdio.h>
main()
{
              int h , m ,s;
              printf("Enter time in format hh mm ss\n");
              scanf("%d%d%d",&h,&m,&s);

              if((h>=0&&h<24)&&(m>=0&&m<60)&&(s>=0&&s<60))

                             printf("Valid\n");
              else
                             printf("Invalid\n");

}

Output:

Enter time in format hh mm ss
12 45 56
Valid


Post a Comment

0 Comments