QUESTION 1 What would be the output of the following code fragment? 0 1 2 0 1 1
ID: 3582707 • Letter: Q
Question
QUESTION 1
What would be the output of the following code fragment?
0 1 2
0 1
1
1 2
4 points
QUESTION 2
Given
Which one of the following is a valid assignment?
4 points
QUESTION 3
Assume that val has been declared as an int for the code fragment below
Which one of the alternatives below will result in “Test C” being printed?
4 points
QUESTION 4
Choose the correct statement
1 represents a false condition
0 represents a false condition
Anything that is not 1 represents a false condition
Non-zero values represent a false condition
4 points
QUESTION 5
Remember that the % operator evaluates to the remainder after integer division e.g. 8 % 4 is 0, 11 % 4 is 3. What is the value of x after the following?
4 points
QUESTION 6
What would be the output of the following code fragment?
4 points
QUESTION 7
a double
a syntax error
a crash when the program runs
an int
4 points
QUESTION 8
All of the elements in an array list with indexes first to last inclusive (first <= last) are to be shifted one position so that a new element can be inserted at list[first]. Which of the following correctly shifts the elements? (Assume that list[last] is the last data element in list, and that last is less than the maximum possible index for list.)
4 points
QUESTION 9
What would be the output of the following code fragment?
4 points
QUESTION 10
Given the following structure declaration
complete the function named area() that computes and returns the area of a right-angled triangle. The area of a right-angled triangle is given by ½ the base multiplied by the height.
Choose the answer that should replace the ???? above
return 0.5 * t.base * t.height;
4 points
QUESTION 11
What would be the output of the following code fragment?
5
10
-5
4 points
QUESTION 12
If you know that your loop must iterate at least one time, it is recommended you use a _________ loop
4 points
QUESTION 13
What would be the output of the following code fragment?
4 points
QUESTION 14
a->b is syntactically correct if?
a is a pointer to a structure in which b is a field
4 points
QUESTION 15
Which of the following is the correct call?
4 points
QUESTION 16
What would be the output of the following code fragment?
4 points
QUESTION 17
What would be the output of the following code fragment?
4 points
QUESTION 18
What is the error in the following code fragment?
A cast is required
Data not initialized
A two-dimensional array is required
Out-of-bounds error
4 points
QUESTION 19
What would be the output of the following code fragment?
None of these
4 points
QUESTION 20
What would be the output of the following code fragment if integer val has the value 1?
PQS
PQ
P
4 points
QUESTION 21
Consider the following structure and function fragments
Which one of the following would have the same effect replacing cp->real = 99.0; in function f() above?
*(cp.real) = 99.0;
*cp.real = 99.0;
cp.real = 99.0;
(*cp).real = 99.0;
4 points
QUESTION 22
3, 6
2, 6
3, 3
3, 1
2, 1
4 points
QUESTION 23
What would be the output of the following code fragment?
4 points
QUESTION 24
Which of the following code fragments would declare a new data type named Book, so that we could declare the following array?
4 points
QUESTION 25
Given the array
How would you access the last element of the array?
cost[3]
A.0 1 2
B.0 1
C.1
D.1 2
Explanation / Answer
1.
D. 1,2
m=0
So first it compares 0<2 and since m is incremented it prints 1 i.e.m=1
then it compares 1<2 and since m is incremented it prints 2 i.e. m=2
and now 2<2 returns false so it exits the loop
2.
D. quantity=(int)value;
In A. you cannot store a double value in an int variable
In B. It is the same thing
In C. you cannot store a string in an int variable
In D. you are using type conversion and storing the double value in an integer
3.
D. val is less than 4
from the given code val will print 'Test A' if the val is greater than or equal to 4. and 'Test B' will never get printed because if val>9 then it is greater than 4 and first if statement will be executed. So Test C is printed if val is less than 4.
4.
B. 0 represents a false condition.
Any non-zero value even if it positive or negative represents a true condition.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.