Home » C++ Programming » Data Structures » Question
  1. What is the output of this program?
    #include 
    using namespace std;
    struct T
    {
    int H;
    int M;
    int S;
    };
    int Seconds(T now);
    int main()
    {
    T t;
    t.H = 6;
    t.M = 3;
    t.S = 15;
    cout << "Total seconds: " << Seconds(t) << endl;
    return 0;
    }
    int Seconds(T now)
    {
    return 3600 * now.H + 60 * now.M + now.S;
    }
    1. Total seconds: 21795
    2. Total seconds: 20000
    3. Total seconds: 21000
    4. Total seconds: 21005
    5. Total seconds: 19000
Correct Option: A

In this program, we are just converting the given hours and minutes into seconds.



Your comments will be displayed only after manual approval.