C Program to Convert Hours into Minutes

The program accepts hours & minutes as an input and print the result to output screen. It uses basic formula to convert the given input to its corresponding minutes.

1 hour = 60 minutes
hours = minutes * 60

Write a program that takes hours and minutes as input and converts it into minutes?

Program:

#include<stdio.h>
int main()
{
int hours,minutes, inminutes;
printf("\n\n\t Please enter hours and minutes \n");
printf("\t hours:minutes = ");
scanf("%d:%d",&hours,&minutes);
inminutes=hours*60;
inminutes=inminutes+minutes;
printf("\n\t %d hours:%d minutes = %d minutes",hours,minutes,inminutes);
return 0;
}

Output:

c program to convert hours to minutes

Explanation:

  1. Getting input from a user
  2. Then, simply multiplying it by 60, that would give minutes
  3. Adding the result with existing minutes
  4. Printing the result

Frequently Asked Question

Q1. How to write a C program to convert years into minutes.

1 years is exactly equal to 525960 minutes. Using this concept, we need to multiply the given input to 525960 to get total minutes.

Program:

#include<stdio.h>
int main()
{
long years,minutes;
printf("\n\n\t Please enter years = ");
scanf("%ld",&years);
minutes=years * 525960;
printf("\n\t %ld years = %ld minutes",years,minutes);
return 0;
}

Output:

Please enter years = 3

3 years = 1577880 minutes

Leave a Reply