Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Lecture Questions Solutions - Programming Concepts - Java | CSCI 261, Exams of Computer Science

Material Type: Exam; Professor: Hellman; Class: PROGRAMMING CONCEPTS - JAVA; Subject: Computer Science; University: Colorado School of Mines; Term: Unknown 1989;

Typology: Exams

Pre 2010

Uploaded on 08/18/2009

koofers-user-f76
koofers-user-f76 🇺🇸

10 documents

1 / 3

Toggle sidebar

Related documents


Partial preview of the text

Download Lecture Questions Solutions - 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 Solution: C 2. All C++ statements end with a(n): A. period B. semi-colon C. colon D. flourish Solution: B 3. (a) Write “This is a comment” as a comment in two different ways for C++. Solution: /*This is a comment */ and //This is a comment. (b) Write the aforementioned comment across multiple lines in C++. Solution: /∗ T h i s i s a comment ∗ / / / T h i s / / i s a / / comment 4. True or False: Indentation is required for the compiler to understand the logical structure of a C++ source listing. Solution: False. Indentation is to help humans visualize the structure of program logic. 5. True or False: Everything in a C++ source listing is translated to the computer program. Solution: False. Comments and indentation are ignored. 6. True or False: A computer program is the compiler and linker translation of only the program source listing. Solution: False. Pre-processor directives “import” code from system libraries. 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 CSCI261 Lecture Questions Simple C++ Solution: A, B, D, and E. 8. What is another name for the name given to a variable? Solution: An identifier. 9. List three examples of valid C++ variable names. Solution: x3, SuperMan, mighty_mouse 10. List two examples of invalid C++ variables names, and state why they are invalid. Solution: 3x: numerals cannot begin variable names. CO2%: The percent sign is an invalid character for variable names. 11. In the following table are four fundamental variables types in C++, list example values for each varible type. double 3.14, -1, 0, 32 int -3, 0, 256 string "c", "word", or "a phrase of several words" bool true, false 12. Which of the fundamental variable types in 11 require(s) a pre-processor directive and a compiler directive? What are they? Solution: The string type requires #include <string>, and using namespace std;. 13. Write two ways to declare a Boolean variable named truth as logical false. Solution: bool truth( false ); or bool truth = false;. 14. Write two ways to declare an integer variable named N with the value 3. Solution: int N( 3 ); or int N = 3;. 15. Write two ways to declare a constant real valued variable named PI as the value π. Solution: const double PI( acos(-1) ); or double PI = acos(-1);. 16. 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 x2 + y− 1z x*x + y - 1/z √ 3x−4y+ xzy sqrt( 3*x - 4*y) + x/(z*y) Page 2
Docsity logo



Copyright © 2024 Ladybird Srl - Via Leonardo da Vinci 16, 10126, Torino, Italy - VAT 10816460017 - All rights reserved