C++ Flashcards

1
Q

What is C++?

A

A programming language

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How do you print out “Welcome” in C++?

A
#include 
using namespace std;
int main()
{
  cout << " Welcome";
  return 0;
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q
int num = 1;
while (num < 4) {
  cout << "num: " << num << endl;
  num++;
}
what the outcome?
A

num: 1
num: 2
num: 3

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How does endl function?

A

endl separates data or text.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

for (int a = 20; a >= 5; a -= 5) {
cout &laquo_space;a &laquo_space;endl;
What the outcome?

A

20
15
10

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q
int a = 4;
do {
  cout << a << endl;
  a++;
} while(a < 10);
What would system print?
A
4
5
6
7
8
9
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is the cout function?

A

cout is use as a insertion operator.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How do you make single comment saying “I have no comment.”?

A

// I have no comment.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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!

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q
int age = 15;
int score = 80;
if (age > 20 || score > 65) {
    cout << "Accepted!" << endl;
} else {
cout<
A

Accepted!

How well did you know this?
1
Not at all
2
3
4
5
Perfectly