Reading quiz 1

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

To specify a value of type char in C++, what set of symbols must be used? -' ' -none of the other choices -It depends upon the implementation -" " -' ' or " " may be used -It depends on whether iostream.h was #include d

' '

What is the output of the following C++ program? Pay attention to spaces. #include <iostream> using namespace std; int main() { for (int i=0; i<10; ++i) { cout << i; cout << " "; } } -123456789 -0123456789 -1 2 3 4 5 6 7 8 9 -none of the other choices -0 1 2 3 4 5 6 7 8 9 10 -0 1 2 3 4 5 6 7 8 9 -0123456789

0123456789

What is the output of the following C++ code? #include <iostream> using namespace std; int main(){ int aNumber = 9; aNumber = aNumber + 1; bool aBool = true; aBool = 9; cout << aBool << endl; return 0; } -false -0 -true -runtime error -1 -none of the other choices -won't compile -9

1

What value does the following code output at line 7? #include <iostream> using namespace std; int main(){ int foo = 77; 7: cout << &foo << endl; return 0; } -compile error because foo was not initialized -1 -a memory address, such as 0x7fffeb17da34 which may vary each time the program is run -No answer text provided. -77 -none of the other choices -0

a memory address, such as 0x7fffeb17da34 which may vary each time the program is run

Consider the following code: #include <iostream> using namespace std; int main( ) { int courseCode = 35670; int *p = &courseCode; while (p != nullptr) { cout << "Pointer p points to " << p << endl; p = nullptr; } 12: cout << "Pointer p points to " << p << endl; } What is the output of line 12? -Pointer p points to 0 -Pointer p points to courseCode -segfault -Pointer p points to 0x7fffa26dfeac -Pointer p points to 35670 -none of the other choices

Pointer p points to 0

Consider the following code: #include <iostream> using namespace std; int main( ) { int courseCode = 35670; int *p = &courseCode; while (p != nullptr) { 9: cout << "Pointer p points to " << p << endl; p = nullptr; } cout << "Pointer p points to " << p << endl; } What is the output of line 9? -segfault -none of the other choices -Pointer p points to 0 -Pointer p points to courseCode -Pointer p points to 35670 -Pointer p points to 0x7ffc1156dbdc

Pointer p points to 0x7ffc1156dbdc

What operator gives a variable's memory address in C++? -It depends upon the implementation -the symbol & -none of the other choices -the symbol id -the symbol *

the symbol &

What is the result of 5/2 in C++? -2.5 -none of the other choices -3 -2 -a runtime error will occur -2.0 -2.50

2

What is the output of this program? #include <iostream> using namespace std; int main() { int grade = 95; if (grade < 60) { cout << 'F'; } else if (grade < 70) { cout << 'D'; } else if (grade < 80) { cout << 'C'; } else if (grade < 90) { cout << 'B'; } else cout << 'A'; } -FDCBA -F -A -C -D -none of the other choices -B

A

SELECT ALL statements that are true of the following line of code: int courseCode = 35760; -It is an initialization -It is a declaration -It dereferences a pointer -It declares a reference -It declares a pointer

It is an initialization It is a declaration


Set pelajaran terkait

Chapter 49 Nervous Systems Key Concepts

View Set

Adaptive Quizzing Questions - Med Surg Ch. 44-46

View Set

Series 7 TO Math computations practice

View Set

Grade 8: Science: Chapter 5: Section 4

View Set

Pharmacology Exam One Practice Questions

View Set

Civics Chapter 27 Section 1 Part 1

View Set

Chapter 34 Assessment and Management of Patients with Inflammatory Rheumatic Disorders

View Set