C program to check whether the time is valid or not
Accept the time as hour , minute and seconds and check whether the time is valid .
/* Aim: To check whether given time is correct or not */
#include<stdio.h>
void main()
{
int h,m,s;
printf("\n Enter your time Hour:-");
scanf("%d",&h);
printf("\n Enter your time Minutes:-");
scanf("%d",&m);
printf("\n Enter your time Seconds:-");
scanf("%d",&s);
if(((h>24) || (h<0)) || ((m>60) || (m<0)) || ((s>60) || (s<0)))
{
printf("\n The Time %d:%d:%d You Entered is NOT Correct \n \n",h,m,s);
}
else
{
printf("\n The Time %d:%d:%d You Entered is Correct \n \n",h,m,s);
}
return 0;
}
Enter your time Hour:-45
Enter your time Minutes:-556
Enter your time Seconds:-56
The Time 45:556:56 You Entered is NOT Correct