intoduction Flashcards

(6 cards)

1
Q

How would you include a file called MyDeclarations.h?

A

#include "MyDeclarations.h"

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

How would you include a standard library called iostream?

A

#include <iostream>

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

How would you include the C header ctype?

A

#include <cctype>

Add a ‘c’ to the beginning instead of a ‘.h’ at the end like in C

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

Write a simple int main() that sums numbers read from the input.

using namespace std

A
#include <iostream>
using namespace std;

int main() {
    int sum = 0, value = 0;
    while (cin >> value)
        sum += value;
    cout << "sum: " << sum << endl;
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How could you have the line cout << "Hello, world!" << endl; without having the line using namespace std; prior?

A
using std::cout;
using std::endl;

these are called “using declarations”

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

Which type of file should never have the line using namespace std;

A

a header (.h) file

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