C++ Program to Print Current Time of Different Time Zone using Do While Loop

C++ Program to Print Current Time of Different Time Zone using Do While Loop

Write C++ Program to Print Current Time of Different Time Zone using Do While Loop

// CPP Program to Print Current Time of Different Time Zone using Do While Loop

#include <iostream>

using namespace std;

int main()
{
	int hour, minute, second, n;

	cout << "Enter Hour :--> ";
	cin >> hour;

	cout << "Enter Minute :--> ";
	cin >> minute;

	cout << "Enter Second :--> ";
	cin >> second;

	cout << "Your Entered Time is :--> " << hour  << " : " << minute << " : " << second;

	int hour1, minute1, second1;   //GST time zone
	hour1 = (hour % 60) - (5 % 60);
	minute1 = (minute % 60) - (30%60);
	second1 = (second % 60);

	int hour2, minute2, second2;  //PST
	hour2 = (hour1 % 60) - (8 % 60);
	minute2 = minute1;
	second2 = second1;

	int hour3, minute3, second3;  //CET
	hour3 = hour2 + 1;
	minute2 = minute1;
	second2 = second1;
	do
	{
		cout << "\n 1. IST";
		cout << "\n 2. GST";
		cout << "\n 3. PST";
		cout << "\n 4. CET";
		cout << "\n Enter 0 to exit";

		cout << "\n Enter your choice :--> ";
		cin >> n;

		if(n == 1)
		{
			cout << "I.S.T :--> " << hour << " : " << minute << " : " << second;
		}
		else if(n == 2)
		{
		    cout << "G.S.T :--> " << hour1 << " : " << minute1 << " : " << second1;
		}
		else if(n == 3)
		{
			cout << "P.S.T :--> " << hour2 << " : " << minute2 << " : " << second2;
		}
		else if(n == 4)
		{
			cout << "C.E.T :--> " << hour3 << " : " << minute3 << " : " << second3;
		}
		else if (n == 0)
        {
			break;
		}
		else
        {
            cout << "Please enter the valid choice";
        }
	}while(n!=0);

	return 0;
}

Output:

Enter Hour :--> 8
Enter Minute :--> 30
Enter Second :--> 30
Your Entered Time is : 8:30:30
 1. IST
 2. GST
 3. PST
 4. CET
 Enter 0 to exit
 Enter your choice :--> 1
I.S.T :- 8:30:30
 1. IST
 2. GST
 3. PST
 4. CET
 Enter 0 to exit
 Enter your choice :--> 2
G.S.T :- 3:0:30
 1. IST
 2. GST
 3. PST
 4. CET
 Enter 0 to exit
 Enter your choice :--> 3
P.S.T :- -5:0:30
 1. IST
 2. GST
 3. PST
 4. CET
 Enter 0 to exit
 Enter your choice :--> 4
C.E.T :- -4:8:0
 1. IST
 2. GST
 3. PST
 4. CET
 Enter 0 to exit
 Enter your choice :--> 0