intoduction Flashcards
(6 cards)
1
Q
How would you include a file called MyDeclarations.h?
A
#include "MyDeclarations.h"
2
Q
How would you include a standard library called iostream?
A
#include <iostream>
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
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; }
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”
6
Q
Which type of file should never have the line using namespace std;
A
a header (.h) file