Convert hours into minutes and seconds in C Programming

  • Tech Area
  • May 12, 2024



In this tutorial, We will see how to convert hours into minutes and seconds in C programming language.

Program to convert hours into minutes and seconds

#include<stdio.h>
#include<conio.h>
void main()
{
int h, m, s;
clrscr();
printf("Enter hours  ");
scanf("%d", &h);
m = h * 60;
s = m * 60;
printf("Minutes is = %d\n", m);
printf("Seconds is = %d\n", s);
getch();
}

Output

Enter hours 2
Minutes is = 120
Seconds is = 7200

The number 2 is entered by the user is stored in the h variable. Hours are converted into minutes using h * 60 and seconds using m * 60. And, minutes & seconds are stored in variable m and s respectively.

printf("Enter hours  ");
scanf("%d", &h);
m = h * 60;
s = m * 60;

The printf() function is used to print minutes and seconds.

printf("Minutes is = %d\n", m);
printf("Seconds is = %d\n", s);


Subscribe us via Email

Join 10,000+ subscriber

Subscribe on YouTube