DOC PREVIEW
Purdue CS 15900 - Exam 1 Study Guide

This preview shows page 1-2-3-4-5-6 out of 17 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 17 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 17 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 17 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 17 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 17 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 17 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 17 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

CS 159 1nd EditionExam # 1 Study GuideClicker Questions and Answers:August 27:1. Which of the following languages needs to be compiled before it can be executed on a computer?a. Natural languageb. Low-level languagec. Programming languaged. Machine languagee. None of the above2. Which of the following represents the memory local to the CPU?a. Secondary memoryb. Main memoryc. Primary memoryd. Registerse. None of the aboveAugust 29:1. Which of the following is NOT a programming or documentation standard of the course?a. Variables will never be acceptable as globalb. The two sections of a function may not overlapc. All code in { and } will be indented two additional spacesd. Declare at most one variable per linee. None of the above2. Which of the following is NOT a rule regarding the selection of an identifier?a. The first character cannot be a digitb. An identifier cannot duplicate a reserved wordc. Only the first 31 characters are significantd. An identifier cannot use a dot charactere. None of the aboveSeptember 3:1. Which of the following is FALSE regarding the printf function?a. The data list is optionalb. The number of placeholders in the format string must correspond to the numberof values in the data listc. The width modifier will limit the number of digits the displayd. The selection of a conversion code depends on the data type to displaye. None of the above2. Which of the following is FALSE regarding the scanf function?a. The scanf function will always make use of its address listb. The scanf function cannot produce outputc. The scanf function can be used to accept the input of multiple valuesd. The scanf function will make use of a \n to advance to the next linee. None of the aboveSeptember 5:1. Which of the following is the value of x after the segment below has been executed?int x = 9;int y = 4;int z = 5;x -= y + z;a. 10b. 8c. 0d. 18e. None of the above2. Which of the following is the value of x after the segment below has been executed?int x;int y = 4;int z = 5;x = ++y – z--;a. -1b. 0c. 1d. -2e. None of the aboveSeptember 10:1. Which of the following will NOT change the contents of a variable’s memory?a. The use of a simple or compound assignment operatorb. The use of the address operator in a scanf functionc. The use of prefix or post-fix operators (++, --)d. The use of an explicit type conversion on a variablee. None of the above2. Which of the following is the value of x after the segment below has been executed?int x = 3;int y = 4;int z = 5;x += z / y * z + y / z * y;a. 4b. 5c. 7d. 8e. None of the aboveSeptember 12:1. Which of the following is FALSE regarding user-defined functions?a. A function can return at most one valueb. A void function has no parametersc. A function must be declared and defined before it can be calledd. The control of the program always returns from the called function to the calling functione. None of the above2. Which of the following is incorrectly placed within the structure of a C program?a. Function headersb. Function declarationsc. Variable declarationsd. Function callse. Function definitionsSeptember 17:1. Which of the following is the value assigned to and stored by the integer variable x in thecode segment below?x = pow(256, ¼);a. 4.0b. 4c. 0d. 1e. None of the above2. Which of the following regarding parameter passing is FALSE?a. The use of parameter identifiers in a function declaration is optionalb. The order in which parameters are passed in a function call is the same order in which they will be received by the called functionc. The names of the variables being passed must correspond with the names of the parameters in called functiond. The use of parameter identifiers in a function definition is requirede. None of the aboveSeptember 19:1.2. ANSWERS:8/27:1. C2. D8/29:1. E2. C9/3:1. C2. D9/5:1. C2. B9/10:1. D2. D9/12:1. B2. A9/17:1. D2. C9/19:1. B2. CChapter 1:The components of a computerNatural languages versus machine languagesWhy secondary memory is slower than primary memory:1. Many secondary devices have moving parts2. Further physically3. Because of its large capacity, its harder to find things4. Why don’t we just use primary? Its too expensiveSteps to creating and running a programStructure Charts/Flow chartsChapter 2:The structure of a program:- Preprocessor directives- Global declarations- int main (void){ Local DeclarationsStatements} //main- Other functions as requiredFew Reminders:1. stdio IS NOT studio2. Once you make a change, recompile the program3. Save save save4. All code between the { and } is indented TWO spaces5. The declarations section and execution sections CANNOT OVERLAP6. Multi-line comments cannot be nested7. The all cap identifiers are reserved for constants onlyData typesVariable1. MUST be declared before they are used2. Only ONE per line, each with its own commentConstants1. Literal constants don’t use memory2. #DEFINE is a preprocessor directive3. Symbolic constants are in all capsInput/Output1. Each value in the printf function (the data list) is separated by a comma:printf(“%d %d %d”, value1, value2, value3);2. Each placeholder represents the data type of the value it is holding the place for:%d is for int3. The scanf function makes use of the ‘&’ symbol Error1. Fix errors topdown (as you fix earlier errors, it might fix later errors)2. Using diagnostic print statements can help significantly in the debugging processChapter 3:Expressions1. Operator vs. operand2. Example:printf(“%d + %d”, a, b, a + b);the ‘a + b’ expression in the data list is evaluated BEFORE it is printed, and the value is never stored in memory3. Modulus: BOTH numbers MUST be of the data type int4. %% in the printf function prints one ‘%’ symbol to the screenAssignment1. “==” (selection for ‘equal to’) and “=” (the assignment operator, used in setting variables equal to a value, etc.) have different meanings, so don’t interchange them!Prefix and Postfix1. Postfix incrementation and decrementation does not change the value immediately (before it is used)2. Don’t modify a single variable more than once in a single expressionType Conversion1. In implicit type conversion, the computer makes the change for you2. Low data types are/should be converted to higher data types so that no data is lostExample: if you change float 2.24 to an int (float 2.24 becomes simply 2) you lose the 0.24 from the value3. In explicit type conversion you specify the change4. The floor


View Full Document

Purdue CS 15900 - Exam 1 Study Guide

Download Exam 1 Study Guide
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Exam 1 Study Guide and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Exam 1 Study Guide 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?