int i = 0;
if(i >= 0)
{
cout << i << endl;
}
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)
int i = 0;
do
{
cout << i << endl;
++i;
} while(i < 3);
string movie = "Sleepy Hollow";
if(movie == "sleepy hollow")
{
cout << "found it" << endl;
}
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;
}
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;
}
What are lines of code that begin with // called?
e.g.,
// what are these called?
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;
}