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

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

#include <stdio.h>

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

	printf("Enter the current time in HH:MM:YY format :--> ");
	scanf("%d:%d:%d",&hour, &minute ,&second );

	printf("Your Entered Time is : %d:%d:%d :--> ", 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
	{
		printf("\n 1. IST");
		printf("\n 2. GST");
		printf("\n 3. PST");
		printf("\n 4. CET");
		printf("\n Enter 0 to exit");

		printf("\n Enter your choice :--> ");
		scanf("%d", &n);

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

	return 0;
}

Output:

Enter the current time in HH:MM:YY format 8:30: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