I have forgotten
my Password

Or login with:

  • Facebookhttp://facebook.com/
  • Googlehttps://www.google.com/accounts/o8/id
  • Yahoohttps://me.yahoo.com
Index » Programming » C/C++ »

Trying to convert hours to minutes in C++

moorvidya\′s Photo
27 Jul 11, 7:33AM
Trying to convert hours to minutes in C++
Hi..This is the coding for convert minutes into hours,

#include <iostream>
    using namespace std;
    int Convert(int);
    int remainder;
    int main ()
    {
    int minutes;
    int convert_to_hours;
    int remainder;
 
    cout << "This program converts minutes to hours and minutes. " << endl;
    cout << "Please enter a number of minutes (an integer) to be converted:" << endl;
    cin >> minutes;
    convert_to_hours = Convert(minutes);
    if (convert_to_hours > 1)
    cout << minutes << " mintes equal to " << convert_to_hours << " hours ";
    else
    cout << minutes << " mintes equal to " << convert_to_hours << " hour ";
    if (remainder > 1)
    cout << "and " << remainder << "minutes." << endl;
    else
    cout << "and " << remainder << "minute." << endl;
    return 0;
    }
 
    int Convert(int minutes)
    {
    int convert_to_hours;
    convert_to_hours = minutes / 60;
    return convert_to_hours;
    }
 
    int Convert(int remainder)
    {
    int remainder;
    remainder = minutes % 60;
    return remainder;
    }
Currently you need to be logged in to leave a message.