Q1. What are the modules of C++ programs called?
A: Founctions.
Q2. What does the following preprocessor directive do?
#include
A: It causes the contents of the iostream file to be substituted for this directive before final compilation.
Q3. What does the following statement do?
using namespace std;
A: It makes definitions made in the std namespace available to a program.
Q4. What statement would you use to print the phrase "Hello,world" and then start a newline?
A:cout << "Hello, world" << endl;
or
cout << "Hello,world\n";
Q5. What statement would you use to creat an integer variable with the name cheeses?
A:int cheese;
Q6. What statement would you use to assign the value 32 to the variable cheeses?
A:cheeses = 32;
Q7. What statement would you use to read a value from keybord input into the variable cheeses?
A:cin >> cheeses;
Q8. What statement would you use to print "We have X varieties of cheese," where the current value of the cheeses variable repliaces X?
A:cout << " We have <<" cheeses" << varieties of cheese" endl;
Q9. What do the following function prototypes tell you about the functions?
int froop(double t);
void rattle(int n);
int prune(void);
A:The first one, the function froop() expects to be called with one argument, which will be type double, and that the function will return a type int value. For instance, it
could be used as follows: int gval = froop(3.14159);
The second one, the function rattle() has no return value and expects an int argument. For instance, it could be used as follows: rattle(37);
The third one, the function prune() returns an int and expects to be used without an argument. For instance, it could be used as follows:
int residue = prune();
Q10. When do you not have to use the keyword return when you define a function?
A: You don't have to use return in a function when the function has the return type void. However, you can use it if you don't give a return value: return;
Q11. Suppose your main() function has the following line: (Note:The answer following is given by myself, and it may not be very precise!)
cout << "Please enter your PIN: ";
And suppose the complier complains that cout is an unkown identifier. What is the likely cause of this complaint, and what are three ways to fix the problem?
A: The likely cause it that the function loses a statement " using namespace std;" to declare a directive of output.
place "using namespace std;" above the main() function;
place"using std::cout; in the main() function;
type as following:" std::cout << " Please enter your PIN: " << std::endl;
THANK YOU!!