Could someone please answer these questions and provide the number and the multi
ID: 3828455 • Letter: C
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 following function definition fragment, what values of myInt does the function test?
} }
What is wrong with the following function body?
}
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,
{
int c;
}
What is the output of the following code fragment that invokes something? (All variables are of type int.)
a. 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';
a. 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?
a. 0-25
b. 0-24
c. 1-25
d. 1-24
13) What is wrong with the following code?
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?
} 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 itExplanation / Answer
1. The given fragment of code tests for the integer values -1,0, 1 because it has if statement given as,
The code given below has no errors,
}
2. The output of the code fragment which invokes something is 1 14 3
3. In thr processing of files for input ,and output the Prompting for file data is not used.
4. The directive necessary for file input output is #include <fstream>
5. The statement which correctly opens an input stream named in_file and attaches it to a file name project.txt is in_file.open("project.txt");
6. Only when reading from the file the external name of the file used in the program.
7. An Object is a variable that has functions as well as data associated with it.
8. A function that is associated with an object is called a member function.
9. The correct way to close a file stream named outFile is close(outFile);
10. The given code below will output the integer value of g.
char ch='G';
11. If the character argument is a digit then the function which returns true is isdigit.
12. The valid index to the given array is 0-24
13. There is nothing wrong in the declaration code
14. In the given code there is mistake in the for statement because Array indexes must be less than the size of the array.
15. The declarations char array[5]={'a','b','c','d','e'}; and char array[5]={''}; declare an array of 5 characters, and initializes them to some known values
16. The declarations of options
c. void f1(int array[100], int size);
d. void f1(float array[], int size);
are correct to expect an array as first argument.
17. The error is in the line 5 of the code.