Question: The ________ qualifier is used to declare read-only variables
Const
Question: A function ________ enables a single function to be defined to perform a task
on many different data types
Template
Question: Give the function header for the following function. Function hypotenuse that
takes two double-precision, floating-point arguments, side1 and side2, and returns a
double-precision, floating-point result.
Double hypotenuse(double side1, double side2)
Question: Give the function header for the following function. Function smallest that
takes three integers, x, y and z, and returns an integer.
Int smallest(int x, int y, int z)
Question: Give the function header for the following function. Function instructions that
does not receive any arguments and does not return a value. [Note: Such functions are
commonly used to display instructions to a user.]
Void instructions(void)
Question: Give the function header for the following function. Function intToDouble
that takes an integer argument, number, and returns a double-precision, floating-point
result.
Double intToDouble(int number)
Question: Write a declaration for the following: Integer count that should be maintained
in a register. Initialize count to 0.
register int count = 0;
Question: Write a declaration for the following: Double-precision, floating-point
variable lastVal that is to retain its value between calls to the function in which it is
defined.
static double lastVal;
Question: Find the error in the following program segment:
int g(void)
{
cout << "Inside function g" << endl;
int h(void)
{
cout << "Inside function h" << endl;
}
}
Int g(void)
{
cout << "Inside function g" << endl;
}
int h(void) {
cout << "Inside function h" << endl;
}
Question: Find the error in the following program segment:
int sum(int x, int y)
{
int result;
result = x + y;
}
Int sum(int x, int y)
{
return x + y;
}
Question: Find the error in the following program segment:
int sum(int n)
{
if (n == 0)
return 0;
else
n + sum(n - 1);
}
Int sum(int n)
{
if (n == 0)
Return 0; else
return n + sum(n - 1);
}
Question: Find the error in the following program segment
void f (double a);
{
float a;
cout << a << endl;
}
Void f (double a)
{
cout << a << endl;
}
Question: Find the error in the following program segment:
void product(void)
{
int a;
int b;
int c;
int result;
cout << "Enter three integers: ";
cin >> a >> b >> c;
result = a * b * c;
cout << "Result is " << result;
return result;}