Docsity

Practice Questions for Exam - Programming Concepts Java | CSCI 261, Exams of Computer Science

Toggle sidebar
bg1
CSCI261 Lecture Questions Simple C++
This worksheet is for your use during and after lecture. It will not be collected or graded, but I think you will find it a
useful tool as you learn C++ and study for the exams. Explain all false answers for the “True or False” questions; in
general, show enough work and provide enough explanation so that this sheet is a useful pre-exam review. I will be
happy to review your answers with you during office-hours, via Email, or instant messaging.
1. All of our C++ programs will have a function named: A.
begin
B.
EntryPoint
C.
main
D.
WinMain
2. All C++ statements end with a(n): A. period B. semi-colon C. colon D. flourish
3. (a) Write “
This is a comment
” as a comment in two different ways for C++.
(b) Write the aforementioned comment across multiple lines in C++.
4. True or False: Indentation is required for the compiler to understand the logical structure of a C++ source listing.
5. True or False: Everything in a C++ source listing is translated to the computer program.
6. True or False: A computer program is the compiler and linker translation of only the program source listing.
7. Which of the following properties does a program variable possess?
A. Size (in bits or bytes)
B. Location (address in memory)
C. URL (universal resource locator)
D. Name
E. Value
8. What is another name for the name given to a variable?
9. List three examples of valid C++ variable names.
10. List two examples of invalid C++ variables names, and state why they are invalid.
11. In the following table are four fundamental variables types in C++, list example values for each varible type.
double
int
string
bool
pf2

Partial preview of the text

Download Practice Questions for Exam - Programming Concepts Java | CSCI 261 and more Exams Computer Science in PDF only on Docsity!

CSCI261 Lecture Questions Simple C++

This worksheet is for your use during and after lecture. It will not be collected or graded, but I think you will find it a useful tool as you learn C++ and study for the exams. Explain all false answers for the “True or False” questions; in general, show enough work and provide enough explanation so that this sheet is a useful pre-exam review. I will be happy to review your answers with you during office-hours, via Email, or instant messaging.

  1. All of our C++ programs will have a function named: A. begin B. EntryPoint C. main D. WinMain
  2. All C++ statements end with a(n): A. period B. semi-colon C. colon D. flourish
  3. (a) Write “This is a comment” as a comment in two different ways for C++.

(b) Write the aforementioned comment across multiple lines in C++.

  1. True or False: Indentation is required for the compiler to understand the logical structure of a C++ source listing.
  2. True or False: Everything in a C++ source listing is translated to the computer program.
  3. True or False: A computer program is the compiler and linker translation of only the program source listing.
  4. Which of the following properties does a program variable possess? A. Size (in bits or bytes) B. Location (address in memory) C. URL (universal resource locator) D. Name E. Value
  5. What is another name for the name given to a variable?
  6. List three examples of valid C++ variable names.
  7. List two examples of invalid C++ variables names, and state why they are invalid.
  8. In the following table are four fundamental variables types in C++, list example values for each varible type. double int string bool

CSCI261 Lecture Questions Simple C++

  1. Which of the fundamental variable types in 11 require(s) a pre-processor directive and a compiler directive? What are they?
  2. Write two ways to declare a Boolean variable named truth as logical false.
  3. Write two ways to declare an integer variable named N with the value 3.
  4. Write two ways to declare a constant real valued variable named PI as the value π.
  5. Assume the real valued variables x, y, and z are properly declared in a C++ program, complete the table by translating the mathematical expression to a C++ statement. Mathematical Expression C++ Statement x^2 + y − (^1) z √ 3 x − 4 y + x zy
  6. (a) Write a C++ statement that prompts a user to enter a value for π.

(b) Suppose your program has a variable named user_pi declared as a double variable type. Write a C++ statement that reads a value for user_pi from the keyboard.

(c) Now, write a C++ statment that prints user_pi to the console.

Page 2