1..Which statement would store a user-entered number into a variable named numQu
ID: 3890346 • Letter: 1
Question
1..Which statement would store a user-entered number into a variable named numQuiz?
Select one:
a. cin >> numQuiz
b. cin << numQuiz;
c. cout << numQuiz
; d. cin >> numQuiz;
2..
What is the output of the following code?
int main() {
int y = 4; int z = 7;
cout << (z % y);
return 0;
}
Select one:
a. 1
b. 3
c. 7
d. 28
4...
Which statement defines an integer variable?
Select one:
a. short numSeconds;
b. int numSeconds;
c. unsigned long long numSeconds;
d. All of the above.
5..
Which is the first statement to contain an overflow?
int main() {
int x = 1000; int y = 10000; // A)
x = x * x; // B)
y = x * x * y; // C)
return 0;
}
Select one:
a. int x = 1000; int y = 10000;
b. x = x * y;
c. y = x * x * y;
d. No statement contains an overflow.
6..
What is main in C++?
Select one:
a. Used to denote a list of statements.
b. The starting place of a program.
c. Represents a particular memory location.
d. Textual representation of a program.
9..
What is the output of the following code?
int main() {
int x = 1; int y = 2;
cout << static_cast<double>(x) / static_cast<double>(y);
return 0;
}
Select one:
a. 0
b. 0.5
c. 1
d. No output. Error in code.
11.
What is the output of the following code?
int main() {
double x = 2.0; double y = 3.0;
cout << pow(x, y);
return 0;
}
Select one:
a. 5
b. 6
c. 8
d. 9
Explanation / Answer
1.
a: cin >> numQuiz : cin syntax is wrong as it gives >> and it also doesn't have ; at the end os statemen
b. cin << numQuiz; : This format is correct to store number in numquiz variable
c. cout << numQuiz; : cout used to display the data
d. cin >> numQuiz; : >> wont work with cin
so option " a. cin >> numQuiz" is correct answer
2. int y = 4; int z = 7;
cout << (z % y);
here z is 7 and y is 4
7%4=3
so option " b. 3 " is correct answer
4.
a. short numSeconds; : This is correct way to declare a variable
b. int numSeconds; : This is correct way to declare a variable
c. unsigned long long numSeconds; : This is correct way to declare a variable
all are correct so option d. all of the above is correcr answer
5.
a. int x = 1000; int y = 10000; : it doesn't rise any overflow
b. x = x * y; : it gives 10000000
c. y = x * x * y; : this will rise an error
so option " c. y = x * x * y; " is correct
6. answer is : "b. The starting place of a program. "
when main detects compiler will undesratnd this is the starting point of program
7.
int x = 1; int y = 2;
cout << static_cast<double>(x) / static_cast<double>(y);
here x=1, y=2
it automatically type casting that variable as we specify static_cast<double>
so 1/2=0.5
so option " b. 0.5" is correct answer
11.double x = 2.0; double y = 3.0;
cout << pow(x, y);
here x=2, y=3
pow(2,3)= 2^3=8
so option " c.8" is correct answer
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.