C++ Flashcards
1
Q
What is C++?
A
A programming language
2
Q
How do you print out “Welcome” in C++?
A
#include using namespace std;
int main() { cout << " Welcome"; return 0; }
3
Q
int num = 1; while (num < 4) { cout << "num: " << num << endl; num++; } what the outcome?
A
num: 1
num: 2
num: 3
4
Q
How does endl function?
A
endl separates data or text.
5
Q
for (int a = 20; a >= 5; a -= 5) {
cout «_space;a «_space;endl;
What the outcome?
A
20
15
10
6
Q
int a = 4; do { cout << a << endl; a++; } while(a < 10); What would system print?
A
4 5 6 7 8 9
7
Q
What is the cout function?
A
cout is use as a insertion operator.
8
Q
How do you make single comment saying “I have no comment.”?
A
// I have no comment.
9
Q
int age = 19; switch (age) { case 14: cout << "You are a preteen!"; break; case 16: cout << "You are an teenager!"; break; case :20 cout << "You are an adult!"; break; default: cout << "This is a default case!"; } What the output?
A
This is a default case!
10
Q
int age = 15; int score = 80; if (age > 20 || score > 65) { cout << "Accepted!" << endl; } else { cout<
A
Accepted!