1 CIS 205 Practice Test George Lamperti. 2 1. A word that has a predefined meaning in a C++ program and cannot be used as a variable name is known as.

Slides:



Advertisements
Similar presentations
Chapter 9 – One-Dimensional Numeric Arrays. Array u Data structure u Grouping of like-type data u Indicated with brackets containing positive integer.
Advertisements

What is a pointer? First of all, it is a variable, just like other variables you studied So it has type, storage etc. Difference: it can only store the.
Chapter 04 (Part III) Control Statements: Part I.
Chapter 10.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Chapter 4 – C Program Control Outline 4.1Introduction.
Computer Science 1620 Loops.
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Adrian Ilie COMP 14 Introduction to Programming Adrian Ilie July 5, 2005.
1 10/20/08CS150 Introduction to Computer Science 1 do/while and Nested Loops Section 5.5 & 5.11.
Introduction to Computers and Programming Lecture 8: More Loops New York University.
Chapter 5: Loops and Files.
Arrays Hanly - Chapter 7 Friedman-Koffman - Chapter 9.
Introduction to Computers and Programming More Loops  2000 Prentice Hall, Inc. All rights reserved. Modified for use with this course.
COMP 14 Introduction to Programming Miguel A. Otaduy May 20, 2004.
Control Structures Control structures control the flow of program execution. 3 types of control structures: sequence, selection.
Chapter 8 Arrays and Strings
CSCI/CMPE 4341 Topic: Programming in Python Chapter 3: Control Structures (Part 1) – Exercises 1 Xiang Lian The University of Texas – Pan American Edinburg,
COMP 110 Introduction to Programming Mr. Joshua Stough September 24, 2007.
CMSC 104, Version 8/061L18Functions1.ppt Functions, Part 1 of 4 Topics Using Predefined Functions Programmer-Defined Functions Using Input Parameters Function.
Functions Parameters & Variable Scope Chapter 6. 2 Overview  Using Function Arguments and Parameters  Differences between Value Parameters and Reference.
DCS 5085 C++ Fundamentals Chapter 4. Overview Basics of a typical C++ Environment C++ Stream Input/Output Classic Stream vs. Standard Stream Iostream.
1 Programming in C++ Dale/Weems/Headington Chapter 7 Functions.
 For Loops › for (variable set; condition; incremental or decrement){ // loop beginning › } // loop end  While loops › while (condition) { // beginning.
 2006 Pearson Education, Inc. All rights reserved Arrays.
Chapter 8 Arrays and Strings
Quiz Answers 1. Show the output from the following code fragment: int a = 5, b = 2, c = 3; cout
C++ Programming: From Problem Analysis to Program Design, Fifth Edition Arrays.
1 INTRODUCTION TO PROBLEM SOLVING AND PROGRAMMING.
CPS120: Introduction to Computer Science Decision Making in Programs.
1 Functions every C++ program must have a function called main program execution always begins with function main any other functions are subprograms and.
Chapter 7 Additional Control Structures. 2 2 void GetYesOrNo (/* out */ char& response) // Inputs a character from the user // Postcondition: response.
1 Three C++ Looping Statements Chapter 7 CSIS 10A.
CS161 Topic #16 1 Today in CS161 Lecture #16 Prepare for the Final Reviewing all Topics this term Variables If Statements Loops (do while, while, for)
Chapter 13 – C++ String Class. String objects u Do not need to specify size of string object –C++ keeps track of size of text –C++ expands memory region.
1 Arrays and Vectors Chapter 7 Arrays and Vectors Chapter 7.
C++ Basics. Compilation What does compilation do? g++ hello.cpp g++ -o hello.cpp hello.
Starting Out with C++ Early Objects ~~ 7 th Edition by Tony Gaddis, Judy Walters, Godfrey Muganda Modified for CMPS 1044 Midwestern State University 6-1.
12/15/2015Engineering Problem Solving with C++, Second Edition, J. Ingber 1 Engineering Problem Solving with C++, Etter Chapter 6 One-Dimensional Arrays.
Introduction to Loops Iteration Repetition Counting Loops Also known as.
Before we get started…. First, a few things… Weighted Grading System Programming Style Submitting your assignments… The char and string variable types.
REPETITION STATEMENTS - Part2 Structuring Input Loops Counter-Controlled Repetition Structure Sentinel-Controlled Repetition Structure eof()-Controlled.
Copyright © 2002 W. A. Tucker1 Chapter 9 Lecture Notes Bill Tucker Austin Community College COSC 1315.
Loops and Files. 5.1 The Increment and Decrement Operators.
 2008 Pearson Education, Inc. All rights reserved. 1 Arrays and Vectors.
CHAPTER 6 ARRAYS IN C++ 2 nd Semester King Saud University College of Applied studies and Community Service CSC 1101 By: Fatimah Alakeel Edited.
PROGRAM ESSENTIALS. TOKENS  SMALLEST UNITS OF A PROGRAM LANGUAGE  Special Symbols  Mathematical Operators  Punctuation  Word Symbols  Key Words.
Repetition Statements (Loops). 2 Introduction to Loops We all know that much of the work a computer does is repeated many times. When a program repeats.
Chapter Looping 5. The Increment and Decrement Operators 5.1.
Copyright 2006 Addison-Wesley Brief Version of Starting Out with C++ Chapter 5 Looping.
 2003 Prentice Hall, Inc. All rights reserved. 1 Basic C++ Programming.
Functions, Part 1 of 3 Topics  Using Predefined Functions  Programmer-Defined Functions  Using Input Parameters  Function Header Comments Reading 
Chapter Looping 5. The Increment and Decrement Operators 5.1.
Lecture 7 – Repetition (Loop) FTMK, UTeM – Sem /2014.
1 Lecture 4: Part1 Arrays Introduction Arrays  Structures of related data items  Static entity (same size throughout program)
CMSC 104, Section 301, Fall Lecture 18, 11/11/02 Functions, Part 1 of 3 Topics Using Predefined Functions Programmer-Defined Functions Using Input.
CC213 Programming Applications Week #2 2 Control Structures Control structures –control the flow of execution in a program or function. Three basic control.
A Sample Program #include using namespace std; int main(void) { cout
1 COMS 261 Computer Science I Title: C++ Fundamentals Date: September 23, 2005 Lecture Number: 11.
Looping I (while statement). CSCE 1062 Outline  Looping/repetition construct  while statement (section 5.1)
1 Chapter 4 - Control Statements: Part 1 Outline 4.1 Introduction 4.4 Control Structures 4.5 if Selection Structure 4.6 if/else Selection Structure 4.7.
CHAPTER 2.2 CONTROL STRUCTURES (ITERATION) Dr. Shady Yehia Elmashad.
Chapter 4 – C Program Control
REPETITION CONTROL STRUCTURE
- Standard C Statements
JavaScript: Functions.
User-Defined Functions
Fundamental Programming
Repetition Statements (Loops) - 2
Based on slides created by Bjarne Stroustrup & Tony Gaddis
Dale Roberts, Lecturer IUPUI
getline() function with companion ignore()
Presentation transcript:

1 CIS 205 Practice Test George Lamperti

2 1. A word that has a predefined meaning in a C++ program and cannot be used as a variable name is known as a _____________________. a. ID b. reserved word c. non-variable word d. word key

3 1. A word that has a predefined meaning in a C++ program and cannot be used as a variable name is known as a _____________________. a. ID b. reserved word c. non-variable word d. word key

4 2. Indicate if the following are input or output statements: a. cin >> x; b. cout << y; c. cin >> a >> b; d. cout << “hello”;

5 2. Indicate if the following are input or output statements: a. cin >> x;Input b. cout << y;Output c. cin >> a >> b; Input d. cout << “hello”; Output

6 3. Which of the following are valid variable names? a. temperature b. cost_of_living c. $deposit d. side2 e. weight_ f. percent%_raise

7 3. Which of the following are valid variable names? a. temperature b. cost_of_living c. $deposit d. side2 e. weight_ f. percent%_raise

8 4. Memory that loses its contents when the power is removed is ______________memory. a. hot b. empty c. volatile d. fixed

9 4. Memory that loses its contents when the power is removed is ______________memory. a. hot b. empty c. volatile d. fixed

10 5. A statement that identifies a variable name to a program is known as a _______________ statement. a. declaration b. static c. variable d. definite

11 5. A statement that identifies a variable name to a program is known as a _______________ statement. a. declaration b. static c. variable d. definite

12 6. When a function is called, the variables or values within the parenthesis are called _____________________. a. parameters b. entries c. arguments d. variables

13 6. When a function is called, the variables or values within the parenthesis are called _____________________. a. parameters b. entries c. arguments d. variables

14 7. The variables within the function parenthesis in the function heading are called _____________________. a. parameters b. entries c. arguments d. variables

15 7. The variables within the function parenthesis in the function heading are called _____________________. a. parameters b. entries c. arguments d. variables

16 8. When inputting characters into char variables, the << operation will skip over _____________________. a. periods b. slashes ( / ) c. numbers d. blanks (white spaces)

17 8. When inputting characters into char variables, the << operation will skip over _____________________. a. periods b. slashes ( / ) c. numbers d. blanks (white spaces)

18 9. Express each value in E-notation (C++ coding convention) a _______________ b. 576,000,000,000.0_______________

19 9. Express each value in E-notation (C++ coding convention) a __5.76e-6 ______ b. 576,000,000,000.0__5.76e11 ______

What values would be assigned to the int variable x in each case? a. x = ; b. x = 5 / 7.6; c. x = 7 / 5; d. x = 7.6 / 5.5;

What values would be assigned to the int variable x in each case? a. x = ; 13 b. x = 5 / 7.6; 0 c. x = 7 / 5; 1 d. x = 7.6 / 5.5; 1

The integer constant or variable within brackets used to reference a particular one-dimensional array cell is called the array __________________________. a. counter b. indicator c. index or subscript d. modifier

The integer constant or variable within brackets used to reference a particular one-dimensional array cell is called the array __________________________. a. counter b. indicator c. index or subscript d. modifier

Do array parameter declarations in a function need to use the & operator if the array is to be changed or modified? a. yes – arrays are never passed by reference b. no – arrays are automatically passed by reference

Do array parameter declarations in a function need to use the & operator if the array is to be changed or modified? a. yes – arrays are never passed by reference b. no – arrays are automatically passed by reference

Write a simple for loop segment to output the following array: Int values[20];

Write a simple for loop segment to output the following array: Int values[20]; for(n = 0; n < 20; n++) cout << values[n];

If an integer array is partially initialized, the unspecified cells will be set to _____________________. a. zero (0) b. blanks c. nulls d. none of the above

If an integer array is partially initialized, the unspecified cells will be set to _____________________. a. zero (0) b. blanks c. nulls d. none of the above

Write a simple for loop segment to allow the user to input new values in the array of question 13.

Write a simple for loop segment to allow the user to input new values in the array of question 13. for(n = 0; n < 20; n++) cin >> values[n];

A loop where the exact number of repeats or repetitions is not known is called an __________________ loop. a. undefined b. ill-defined c. indefinite d. counted

A loop where the exact number of repeats or repetitions is not known is called an __________________ loop. a. undefined b. ill-defined c. indefinite d. counted

Write the section of code that could be used to input and sum a list of exactly 25 values.

Write the section of code that could be used to input and sum a list of exactly 25 values. count = 0.0; sum = 0.0; while(count < 25.0) { cin >> value; sum = sum + value; count = count + 10; }

Write a section of code that could be used to output YES if the variable cost is greater than or output NO if cost is less than or equal to

Write a section of code that could be used to output YES if the variable cost is greater than or output NO if cost is less than or equal to if(cost > 100.0) cout << “YES”; else cout << “NO”;

If the user is to enter a sentinel value at the end of an indefinite list of vaues, the programmer would use an ____________________ loop. a. indefinite b. undefined c. counted d. ill-defined

If the user is to enter a sentinel value at the end of an indefinite list of vaues, the programmer would use an ____________________ loop. a. indefinite b. undefined c. counted d. ill-defined

If the user is to enter a sentinel value at the end of an indefinite list of values, the programmer would use an ____________________ loop. a. indefinite b. undefined c. counted d. ill-defined

Draw a symbolic diagram or flowchart of a program segment that could be used to output the message PASS or FAIL for a given test score. Assume 65 and above is a passing score

42 Score>=65? cout<<”PASS”cout<<”FAIL” TrueFalse Score>=65? cout<<“PASS”Cout<<“FAIL” True False

Which Boolean operator should be used in a condition to test if either variable a or variable b is true? _____________________. _____________________. a. && b. ! c. == d. ||

Which Boolean operator should be used in a condition to test if either variable a or variable b is true? _____________________. _____________________. a. && b. ! c. == d. ||

A good rule of thumb is always to place _____________________ around both choices of a two-choice if. a. [] b. () c. {} d. //

A good rule of thumb is always to place _____________________ around both choices of a two-choice if. a. [] b. () c. {} d. //

Which Boolean operator should be used in a condition to test if both variable a and variable b is true? a. && b. ! c. == d. ||

Which Boolean operator should be used in a condition to test if both variable a and variable b is true? a. && b. ! c. == d. ||

Consider the following for loop: for(n=0; n<10; n++) cout << “hello” << endl; How many different lines will the above loop produce? a. 9 lines b. 11 lines c. 10 lines d. 0 lines

Consider the following for loop: for(n=0; n<10; n++) cout << “hello” << endl; How many different lines will the above loop produce? a. 9 lines b. 11 lines c. 10 lines d. 0 lines

Rewrite the following definite loop using a for statement. Int count; Count = 0; While(count < 25) { cout << “count is “ << count << endl; count++;}

Rewrite the following definite loop using a for statement. Int count; Count = 0; While(count < 25) { cout << “count is “ << count << endl; count++;} for(int count = 0; count < 25; count++) cout << “count is “ << count << endl;

If a function does not return a value, with what type must the function be declared? __________________. __________________.

If a function does not return a value, with what type must the function be declared? void functions do not return a value void functions do not return a value

If SomeFuncA() calls or invokes SomeFuncB(), in what order should these two functions be defined? functions be defined? a. SomeFuncA() then SomeFuncB() b. SomeFuncB() then SomeFuncA() c. the order does not matter

If SomeFuncA() calls or invokes SomeFuncB(), in what order should these two functions be defined? functions be defined? a. SomeFuncA() then SomeFuncB() b. SomeFuncB() then SomeFuncA() c. the order does not matter

The following program is required to calculate the square root of a variable. What must be included for the library function sqrt() to be accessible? must be included for the library function sqrt() to be accessible? ______________________. ______________________. Void main() { float voltage; cin << voltage; cout << “root is: “ << sqrt(voltage);

The following program is required to calculate the square root of a variable. What must be included for the library function sqrt() to be accessible? must be included for the library function sqrt() to be accessible? #include #include Void main() { float voltage; cin << voltage; cout << “root is: “ << sqrt(voltage);

The >> extraction operator reads a character sequence into a string variable until a _____________ ______________ is detected. _____________ ______________ is detected. a. carriage return b. white space c. null operator d. number value

The >> extraction operator reads a character sequence into a string variable until a _____________ ______________ is detected. _____________ ______________ is detected. a. carriage return b. white space c. null operator d. number value

To test if a string variable contains a particular word, the ____________________ function can be used. a. find() b. islike() c. ismember() d. memberof()

To test if a string variable contains a particular word, the ____________________ function can be used. a. find() b. islike() c. ismember() d. memberof()

What is the initial value of a string variable that is not initialized? a. blank b. zero c. empty or null string d. whatever is in that piece of allocated memory

What is the initial value of a string variable that is not initialized? a. blank b. zero c. empty or null string d. whatever is in that piece of allocated memory

The ______________ variable type may be used to hold a sequence of values as opposed to a single value like int or float.

The String variable type may be used to hold a sequence of values as opposed to a single value like int or float.

The getline() function reads a character sequence into a string variable until the end of a ___________________ is reached. a. sentence b. executable line of code c. ; (semicolon) d. line

The getline() function reads a character sequence into a string variable until the end of a ___________________ is reached. a. sentence b. executable line of code c. ; (semicolon) d. line

69 End of Final Practice Test