STUDY TEST.
Given the following code:
int main()
{
int a;
cin >> a;
if (a = 7) {
cout << "yes";
}
else {
cout << "no";
}
}
What would be printed to the screen ...
If the user typed 0?
if the user typed 100? - CORRECT ANSWER yes; yes
int main()
{
int i;
for (i = 0;i < 10;i++);;;
, cout << 'A';
cout << i;
}
How many times is A printed to the screen?
What is the value of i printed to the screen? - CORRECT ANSWER 1 time because there are no brackets;
10
Declare a vector of 1000 strings, each with the initial value "Hello", in one statement. - CORRECT
ANSWER vector<string> v(1000,"Hello");
Given the following code:
int main()
{
string line;
........
while (????) {
cout << "Got a line: " << line << '\n';
}
}
Given that fin is an open file stream, write the code for ???? that will get a single line from fin and store
that line into the variable "string line". - CORRECT ANSWER getline(fin, line)
Given the following code: