DOC PREVIEW
Purdue CS 15900 - CS 159 Final Exam Study Guide

This preview shows page 1-2-23-24 out of 24 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 24 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 24 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 24 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 24 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 24 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Lab Quiz 01A variable declaration includes both a data type and an identifier. TRUEThe precision modifier used to display a floating-point value specifies the number ofdigits to display to the right of the decimal point.TRUEThe local declaration and executable statement sections of a function must never be permitted to overlap.TRUEIt is a course standard to place a space between all operators and operands. TRUEThe parameters of the scanf function are the format string and address list. TRUELab Quiz 02Simplify the following expression: 84 % 0 Arithmetic ExceptionSimplify the following expression: 0 % 84 0Simplify the following expression: 51 % 5 1Simplify the following expression: 29 % 11 7Given that x = 3, y = 2, z = 0 and each variable is an integer, what is thevalue assigned to z after the following expression: z = ++x + --y;5Given that x = 3, y = 2, z = 0 and each variable is an integer, what is thevalue assigned to z after the following expression: z = x++ + --y;4Given A and B are integer variables, both are greater than zero, and A isless than B. What is NOT a possible result of the expression: B % A?AGiven that x = 3, y = 2, z = 5 and each variable is an integer, what is thevalue assigned to x after the following expression: x *= z - y;9Given that x = 3, y = 2, z = 5 and each variable is an integer, what is thevalue assigned to x after the following expression: x += z / y;5The abs function is found in stdlib.h TRUELab Quiz 03What is the result of the following expression: (float) 4 / 5 0.8What is the result of the following expression: (float) 4 / (float) 5 0.8The result of the following expression is 18: (int) (17.7 + 0.5)TRUEThe result of the following expression is 18: (int) 17.7 + 0.5 FALSEThe smallest possible value of the following expression for any non-negative integer x is 0: (x + 2) % (x + 1)TRUEWhat is the result of the following expression: 4 / 5.0 / 2 0.4What is the result of the following expression: 4 / 5 / 2.0 0.0What is the result of the following expression: ((int) 4.2 / 5) 0What is the result of the following expression: 13 / 2.5 5.2Lab Quiz 04Parameters being received by a function will be commented to the right of where they are defined.FALSEThe function definition requires the data types and identifiers for each parameter. TRUEThe first line of the function definition is known as the function header. TRUEData sent from the calling function to the function being called will be received in the same order in which it was passed.TRUEA variable declared in the local declaration section of a function can have the same identifier as one of the parameters of the function.FALSEParameters in the function header are initialized by the value they receive from the calling function.TRUEThe code segment below will display 23 for the value of the variable r.TRUEint strange(int, int);int main(){ int a = 3; int b = 5; int r; r = strange(a, b); printf("r = %d\n", r); return(0);}int strange(int x, int y){ int t; int z; t = x + y; z = x * y; return(t + z);}The code segment below will display 73 for the value of the variable r.int strange(int, int);int main(){ int r; r = strange(strange(3, 2), 5); printf("r = %d\n", r); return(0);}int strange(int x, int y){ int t; int z; t = x + y; z = x * y; return(t + z);}FALSELab Quiz 05What is the result of the following expression? !(2 / 3) TRUEWhat is the result of the following expression? 3 || 6 && 0 TRUEWhat is the result of the following expression? 17 % 3 && 21 % 7 || 8 != 8 FALSEWhat is the result of the following expression? 3 || -3 || 10 || -10 TRUEIt is possible to determine if any parameters are passed to a function by address from an example call to the function.TRUEWith the use of pass by address it is now permissible for a function to be written to complete several sub-tasks of the program.FALSERather than passing the only parameter by address to a void function it is better to make use of the return statement in the function to send the neededvalue to the calling function.TRUEHow many of the user-defined functions called by the main function below are void functions?int main(){ int value1; int value2; value1 = getData(1); value2 = getData(2); swapValues(&value1, &value2); displayResults(value1, value2); return(0);} 2Which of the following is the function declaration of the user-defined function calcPayment given the main function below?int main(){ float annualRate; int term; float principal; float moPay; annualRate = getAnnualRate(); term = getTerm(); principal = getPrincipal(); moPay = calcPayment(annualRate, principal, term); printAnalysis(term * 12, annualRate, principal, moPay); printAlternatives(term, annualRate, principal); return(0);}float calcPayment(float, float, int); Which of the following is the function declaration of the user-defined function getData given the main function below?int main(){ int value1; int value2; value1 = getData(1); value2 = getData(2); swapValues(&value1, &value2); displayResults(value1, value2); return(0);} int getData(int);Lab Quiz 06A terminal semicolon after an “if condition” is optional. FALSEThe loop control variable is commonly a part of the loop control expression and the recipient of the actions of the loop update.TRUEThe complement of x > 0 && x < 10 is x >= 0 && x <= 10 FALSENo amount of control structures are permissible in the main function. FALSEIf you can determine the number of times the actions found in the body of the loop are executed then you have a counter-controlled process.TRUEThe control expression that follows the keyword switch may be an integer or character expression.TRUEIt is a logical error to associate two switch case labels with a common set of actions. FALSEThe number of times the loop control expression is evaluated equals the number of iterations in a post-test loop.TRUEThe following two logical expressions are equivalent: x > 3 and !(x <= 3) TRUEThe complement of x > 3 is !(x > 3) TRUELab Quiz 07The only way to stop a program with an infinite loop is to shut down your terminal software.FALSEWhich of the following is the output generated by the code segment below? int x = 10; int y = 0; while(x >= 2 * y) { x++; y += 3; } printf("y: %d\n", y);y:9A nested loop is a repetitive process contained insider of another repetitive process. TRUEYou can make use of x++, ++x, x += 1, and x = x + 1 interchangeably as the update (third) expression of a for loop.TRUEAll while loops can be converted into


View Full Document

Purdue CS 15900 - CS 159 Final Exam Study Guide

Download CS 159 Final Exam 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 CS 159 Final Exam 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 CS 159 Final Exam 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?