You have up to 20 minutes. Please write your answers on this page, and your name at the top. You may not use the computer, notes, or books.
Which of the following statements prints exactly this text, as shown:
We the
PEOPLE
Select all that apply.
cout << "We the PEOPLE" << endl;
cout << "We the" << "endl" << "PEOPLE" << "endl";
cout << "We" << " the" << endl << "PEOPLE" << endl;
cout << "We the" << endl << "PEOPLE" << endl;
cout << "WE the" << endl << "people";
Both c and d produce the required output.
Given a variable maxDays = 14
, which statement prints 14
?
cout >> maxDays;
cout << maxDays;
cout << "maxDays";
print maxDays;
Only b.
Circle and describe any syntax errors in this program:
#include <iostream>
using namespace;
INT main( )
{
int score = 100;
cout << 'Hello world.' << endl
cout < score < '%';
return 0;
}
std
INT
<<
on second cout
#include <iostream>
using namespace std;
int main()
{
int lisa = 8;
int bart = lisa + 2;
int maggie = bart - 7;
cout << maggie << ", " << bart << lisa << endl;
return 0;
}
3, 108
endl
.#include <iostream>
#include <cmath>
using namespace std;
int main()
{
cout << 9 / 2 << endl; // _______
cout << 7 / 2.0 << endl; // _______
cout << 17 % 2 << endl; // _______
cout << 31 % 7 << endl; // _______
cout << pow(3,3) << endl; // _______
cout << sqrt(25) << endl; // _______
cout << floor(9.8) << endl; // _______
cout << sqrt(pow(2,4))+1 << endl; // _______
return 0;
}
4
3.5
1
3
27
5
9
5