string line = "Look at me, I can write C++ code!";
cout << "Hey! " << line << endl;
int i = 0;
if(i >= 0)
{
cout << i << endl;
}
void printMe(int i)
{
cout << i << endl;
}
/*********************/
printMe(1);
printMe(2);
If I have an int called 'n', how do I read an integer from the user into it?
bool ShouldContinue = true;
while(ShouldContinue)
{
ShouldContinue = false;
cout << "hi!" << endl;
}
int n = 6;
if(isDivisibleBy2(n))
{
cout << "divisible by 2" << endl;
}
else if(isDivisibleBy3(n))
{
cout << "divisible by 3" << endl;
}
What are the things between the parentheses called?
int sum(int n1, int n2)
void printMe(int i)
{
cout << i << endl;
}
/*********************/
int i = 0;
printMe(i);
i = 5;
printMe(5);
What object of the istream class is used to accept the input from the standard input stream?
cin
int i = 0;
do
{
cout << i << endl;
++i;
} while(i < 3);
string movie = "Sleepy Hollow";
if(movie == "sleepy hollow")
{
cout << "found it" << endl;
}
void printMe(int i)
{
cout << i << endl;
}
/*********************/
int n = 37;
++n;
printMe(n);
Imagine numbers.txt contains:
37
25
-2
54
What does the following code print out?
ifstream f("numbers.txt");
while(f.good())
{
string s;
getline(f, s);
cout << s << endl;
}
37
25
-2
54
int i = 3;
do
{
cout << i << endl;
--i;
} while(i > 0);
string movie = "Terminator";
if(movie == "Terminator") && movie.find("Term") != string::npos)
{
cout << "found it" << endl;
}
Given:
float calculateArea(float length, float width);
Is this statement:
A - Function definition
B - Function prototype
C - Function call
D - Function method
B - Function prototype
void changeMe(int i)
{
i = 5;
}
/*********************/
int n = 37;
changeMe(n);
cout << n << endl;
6
for(int i = 0 ; i < 5; ++i)
{
cout << (i + 1 * 2) << endl;
}
string movie = "Lord of the Rings";
string userMovie = "lord";
if(movie == userMovie)
{
cout << "case 1" << endl;
}
else if(movie.find(userMovie) != string::npos)
{
cout << "case 2" << endl;
}
else
{
cout << "else" << endl;
}