C Program to print the AM and PM based on time
Accept an integer n as input
For 0<=n && n<12
For 12<=n && n<24
For all other numbers, display "INVALID INPUT".
For example:
Input | Result |
---|---|
0 | AM |
13 | PM |
24 | INVALID INPUT |
Code
#include <stdio.h>
int main(){
int n;
scanf("%d",&n);
if(0<=n && n<12){
printf("AM");
}
else if(12<=n && n<24){
printf("PM");
}
else{
printf("INVALID INPUT");
}
}
Other Programs