COSC Practice Test with 100 % Correct Answers
Which of the following function prototypes is valid?
a. int funcTest(int x, int y, float z){}
b. funcTest(int x, int y, float){};
c. int funcTest(int, int y, float z)
d. int funcTest(int, int, float); - Answer-d. int funcTest(int, int, float);...
Which of the following function prototypes is valid?
a. int funcTest(int x, int y, float z){}
b. funcTest(int x, int y, float){};
c. int funcTest(int, int y, float z)
d. int funcTest(int, int, float); - Answer-d. int funcTest(int, int, float);
Which of the following function prototypes is valid?
a. int funcExp(int x, float v);
b. funcExp(int x, float v){};
c. funcExp(void);
d. int funcExp(x); - Answer-a. int funcExp(int x, float v);
Given the following function prototype:
int myFunc(int, int);
which of the following statements is valid? Assume that all variables are properly
declared.
a. cin >> myFunc(y);
b. cout << myFunc(myFunc(7, 8), 15);
c. cin >> myFunc('2', '3');
d. cout << myFunc(myFunc(7), 15); - Answer-b. cout << myFunc(myFunc(7, 8), 15);
The statement:
return 8, 10;
returns the value ____.
a. 8 b. 10 c. 18 d. 80 - Answer-b. 10
The statement:
return 37, y, 2 * 3;
returns the value ____.
a. 2 b. 3 c. y d. 6 - Answer-d. 6
The statement: return 2 * 3 + 1, 1 + 5; returns the value ____.
a. 2 b. 3 c. 6 d. 7 - Answer-c. 6
Suppose that printHeading is a function without any parameters. Which of the following
is a valid function heading?
, a. void printHeading();
b. void printHeading()
c. void printHeading(noParameters);
d. void printHeading(void) - Answer-b. void printHeading()
Which of the following is a legal C++ function definition?
a. void funcTest(int& u, double& v)
{
cout << u << " " << v << endl;
}
b. void funcTest(int& u, double& v);
{
cout << u << " " << v << endl;
}
c. void funcTest(int& u, double& v)
(
cout << u << " " << v << endl
)
d. void funcTest(int& u, double& v)
[
cout << u << " " << v << endl;
] - Answer-a. void funcTest(int& u, double& v)
{
cout << u << " " << v << endl;
}
There are two types of ____ parameters: value parameters and reference parameters.
a. actual b. formal
c. active d. passive - Answer-b. formal
1. The standard header file for the abs(x)function is ____.
a.< cmath > b.< ioinput >
c.< cctype >d.< cstdlib > - Answer-1. ANS: D < cstdlib > 1
2. To use the predefined function tolower, the program must include the header file
____.
a. cctype b. iostream
c. cmath d. cstdlib - Answer-a. cctype
3. The output of the statement
cout << tolower('$') << endl; is ____.
The benefits of buying summaries with Stuvia:
Guaranteed quality through customer reviews
Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.
Quick and easy check-out
You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.
Focus on what matters
Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!
Frequently asked questions
What do I get when I buy this document?
You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.
Satisfaction guarantee: how does it work?
Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.
Who am I buying these notes from?
Stuvia is a marketplace, so you are not buying this document from us, but from seller Scholarsstudyguide. Stuvia facilitates payment to the seller.
Will I be stuck with a subscription?
No, you only buy these notes for $9.99. You're not tied to anything after your purchase.