Examveda

What will be the output of the following C++ code?
#include <iostream>
using namespace std;
struct Time 
{
    int hours;
    int minutes;
    int seconds;
};
int toSeconds(Time now);
int main()
{
    Time t;
    t.hours = 5;
    t.minutes = 30;
    t.seconds = 45;
    cout << "Total seconds: " << toSeconds(t) << endl;
    return 0;
}
int toSeconds(Time now)
{
    return 3600 * now.hours + 60 * now.minutes + now.seconds;
}

A. 19845

B. 20000

C. 15000

D. 19844

Answer: Option A


Join The Discussion

Related Questions on Structures and Unions in C plus plus

What is a structure in C++?

A. A collection of functions

B. A reserved keyword in C++

C. A user-defined data type containing variables of different data types

D. A way to declare arrays of data