90 Questions and 100% Verified Correct Answers
Guaranteed A+
(15.20) What will be the output of the following complete program?
#include <iostream>
#include <string>
using namespace std;
int main() { set<string> cities;
cities.insert("Los Angeles");
cities.insert("Anaheim");
cities.insert("Berkeley");
cities.insert("Anaheim");
for (auto it = cities.begin(); it != cities.end(); it++)
{ cout << " " << *it; }
return 0; }
Anaheim Anaheim Berkeley Los Angeles
Anaheim Berkeley Los Angeles
Los Angeles Anaheim Berkeley
Compiler error, no output as set<> will be undefined. - CORRECT ANSWER: Compiler
error, no output as set<> will be undefined.
A programmer working on an auto rental application realizes that she needs to create
many Car objects in this application. What does she need to do in order to define a Car
class?
,Write a Car class that defines the data members and functions that Car objects will
have.
Define both global data and functions to represent car data and behavior.
Define a set of global variables to store data for Car objects.
Write a set of functions that accepts a car as a parameter. - CORRECT ANSWER: Write
a Car class that defines the data members and functions that Car objects will have.
According to NUMA architecture, all memory in a computer can be accessed and the
retrieval times are constant. - CORRECT ANSWER: False
Assume the following C++ code segment:
struct student
{
string name;
int age;
char grade;
};
student s1, *sptr;
sptr = &s1;
s1.name = "MasterGold";
What code would you use to set Master Gold's age to 49?
The correct answer is not listed.
student.age = 49;
sptr->age = 49;
sptr.age = 49; - CORRECT ANSWER: sptr->age = 49;
, Assume the following C++ code segment:
struct student
{
string name;
int age;
char grade;
};
student s1, *sptr;
sptr = &s1;
s1.name = "MasterGold";
What code would you use to set Master Gold's grade to A?
The correct answer is not listed
sptr.grade = 'A'
s1->grade = 'A';
MasterGold->grade = 'A'; - CORRECT ANSWER: The correct answer is not listed
Consider a function named avg, which accepts four numbers as integers and returns
their average as a double. Which of the following is the correct statement to call the
function avg?
avg(2, 3.14, 3, 5);
double average = avg(2, 3, 4, 5);
double average = avg("2", "3", "4", "5");
avg(); - CORRECT ANSWER: double average = avg(2, 3, 4, 5);