Question
Could someone please answer these questions and provide the number and the multiple choice answer next to the question number. Thank You!! 1) Given the
Could someone please answer these questions and provide the number and the multiple choice answer next to the question number. Thank You!!
1) Given the following function definition fragment, what values of myInt does the function test?
int doSomething(int myInt)
{ if(myInt{ // do some stuff here} }
What is wrong with the following function body?
void calculate(int count, float price, float& cost){ if (countelse cost=0.0;cost=count*price; return;}
a. void functions may not have a return statement.
b. void functions must return a value
c. nothing
d. cannot mix pass-by-reference and pass-by-value parameters
2) Given the function definition,
void something ( int a, int& b ){ int c;
c = a + 2; a = a * 3; b = c + a;}
What is the output of the following code fragment that invokes something? (All variables are of type int.)
r = 1; s = 2; t = 3; something(t, s); couta. 1 14 3
b. 1 10 3
c. 5 14 3
d. 1 14 9
3) Which of the following is not used when processing files for input and output
a. Opening the file stream
b. Ensuring that the stream opened
c. Closing the stream
d. Prompting for file data
4) Which include directive is necessary for file IO
a. #include
b. #include
c. #include
d. #include
5) Which statement correctly opens an input stream named in_file and attaches it to a file name project.txt?
i. in_file=project.txt j. in_file="project.txt" k. in_file.open("project.txt"); l. in_file.open(project.txt);
6) When is the external name of the file used in the program?
m. Any time you read or write to the file
n. Never
o. Only when reading from the file p. When opening the file stream
7) A/An __________ is a variable that has functions as well as data associated with it.
a. member
b. int c. object
d. float
8) A function that is associated with an object is called a _________ function.
a. input b. output c. member d. instantiated
9) Which of the following is the correct way to close a file stream named outFile?
a. outFile.close(); b. outFile.close; c. outFile.close("project.txt"); d. close(outFile);
10) What is the output of the following code?
char ch='G';
couta. G b. g c. the integer value of 'g' d. the integer value of 'G'
11) Which function returns true if the character argument is a letter?
a. isdigit
b. islower
c. isalpha
d. isspace
12) What are the valid indexes for the array shown below?
int myArray[25];a. 0-25
b. 0-24
c. 1-25
d. 1-24
13) What is wrong with the following code?
float scores[10], total;a. Cannot declare regular and array variables together. b. Arrays must be integers c. The 10 should be replaced with a variable name, whose value is input from the user d. Nothing.
14) What is wrong with the following code fragment?
const int SIZE = 5; float scores[SIZE]; for(int i = 0; i{ cout} cin >> scores[i];
a. Array indexes start at 1 not 0 b. Arrays must be integers c. Array indexes must be less than the size of the array d. Should be cin >> scores[0];
15) Which of the following declare an array of 5 characters, and initializes them to some known values?
a. char array[5]={'a','b','c','d','e'};
b. char array[4]={'a','b','c','d','e'};
c. char array[5]={''};
d. char array[]={'a','b','d','e'};
e. A and C
f. B and D
g. all of the above
16) Which of the following function declarations correctly expect an array as the first argument?
a. void f1(int array, int size);
b. void f1(int& array, int size);
c. void f1(int array[100], int size);
d. void f1(float array[], int size);
e. All of the above
f. C and D
g. A and B
17) The following function definition has an error in it. On what line is this error?
a. 0
b. 2
c. 5
d. 6
e. 2
0. void fl (const double array int size) 1. 2. int i 0; 3. while (i size 4. array [i 2; cout array ij it
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started