Tuesday, January 16, 2018

Write a program that reads in one number specifying the length of the film in seconds and then writes out the length of the film in hours, remaining minutes and remaining seconds.

// Chapter 15 - Exercise 3
#include <iostream>
using namespace std;

int main()
{
    cout << "Enter length of movie in minutes: " << endl;

    int length;
    cin >> length;

    int a = length / 60, b = length % 60, c = b * 60;

    cout << a << "hours & " << b << "min & " << c << "sec" << endl;

    return 0;
}

No comments:

Post a Comment