Question 18 What is the output of the following program segm
Question 18
What is the output of the following program segment?
int main()
{
float hours = 8;
float payRate = 5.5; // per hour
float grossPay = 0.0;
grossPay = calcGrossPay (hours, payRate);
displayGrossPay(grossPay);
return 0;
}
float calcGrossPay(float hrs, float payRt)
{
return hrs * payRt;
}
void displayGrossPay(float gPay)
{
cout <<\"Gross Pay is \"<< gPay << endl;
}
44
Gross Pay is 44
Gross Pay is gPay
All of the above
--------------------------------------------------------------
Question 19
Assume a program uses the statement name = getFirstName(); to call the getFirstName function. (name is a string variable). Which of the following is a valid function header for the getFirstName function?
void getFirstName(string firstName)
string getFirstName(string firstName)
string getFirstName()
void getFirstName()
--------------------------------------------------------------
Question 20
How many parameters does the function calcGrossPay require?
int main()
{
float hours = 8;
float payRate = 5.5; // per hour
float grossPay = 0.0;
grossPay = calcGrossPay (hours, payRate);
displayGrossPay(grossPay);
return 0;
}
float calcGrossPay(float hrs, float payRt)
{ return hrs * payRt;
}
void displayGrossPay(float gPay)
{
cout <<\"Gross Pay is \"<< gPay << endl;
}
0 parameters
1 parameter
2 parameter
3 parameter
--------------------------------------------------------------
Question 21
The cout<< sales[0] + sales[1]; statement will __________.
Use the following 5 element array, named sales, to answer this question.
10000 12000 900 500 20000
display 22000
display 10000 + 12000
display sales[0] + sales[1]
result in an error
Solution
Answers:
Question 18
What is the output of the following program segment?
I have excecuted the program succesfully, got output
the solution is Gross Pay is 44
Question 19
Assume a program uses the statement name = getFirstName(); to call the getFirstName function. (name is a string variable). Which of the following is a valid function header for the getFirstName function?
the solution is :void getFirstName(string firstName)
Question 20
How many parameters does the function calcGrossPay require?
the solution is 2 parameter
Question 21
The cout<< sales[0] + sales[1]; statement will __________.
Use the following 5 element array, named sales, to answer this question.
10000 12000 900 500 20000
the solution is display 22000

