Predict the Output
A) (Assume the user enters George Washington.)
#include
#include
#include
using namespace std;
int main()
{
string userInput;
cout << "What is your name? ";
cin >> userInput;
cout << "Hello " << userInput << endl;
return 0;
}
B) (Assume the user enters George Washington.)
#include
#include
#include
using namespace std;
int main()
{
string userInput;
cout << "What is your name? ";
getline(cin, userInput);
cout << "Hello " << userInput << endl;
return 0;
}
C) (Assume the user enters 36720152. Use a calculator.)
#include
#include
using namespace std;
int main()
{
long seconds;
double minutes, hours, days, months, years;
cout << "Enter the number of seconds that have\n";
cout << "elapsed since some time in the past and\n";
cout << "I will tell you how many minutes, hours,\n";
cout << "days, months, and years have passed: ";
cin >> seconds;
minutes = seconds / 60;
hours = minutes / 60;
days = hours / 24;
years = days / 365;
months = years * 12;
cout << fixed << showpoint << setprecision(4) << left;
cout << "Minutes: " << setw(6) << minutes << endl;
cout << "Hours: " << setw(6) << hours << endl;
cout << "Days: " << setw(6) << days << endl;
cout << "Months: " << setw(6) << months << endl;
cout << "Years: " << setw(6) << years << endl;
return 0;
}
We need at least 10 more requests to produce the solution.
0 / 10 have requested this problem solution
The more requests, the faster the answer.