Write a program in C++ to input hours and minutes and show the result time is am or pm.

#include<iostream>

using namespace std;

int main()

{

int hours,minutes;

cout<<"enter your hours and minutes in 24 format:\n";

cout<<"enter your hours: ";

cin>>hours;

cout<<"enter your minutes: ";

cin>>minutes;

switch(hours>=0 && hours<=12)

{

case 1:

cout<<"your time is am";

break;

case 0: 

switch(hours>=12 && hours<=24)

{

case 1:

cout<<"your time is pm";

break;

case 0:

cout<<"you enter wrong number";

   }

}

}


Output:

Write a program in C++ to input hours and minutes and show the result time is am or pm.

Post a Comment

Please do not enter any spam link in the comment box.

Previous Post Next Post