Name MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question.

Similar documents
CS2255 HOMEWORK #1 Fall 2012

Exam 3 Chapters 7 & 9

Homework #3 CS2255 Fall 2012

FORM 2 (Please put your name and form # on the scantron!!!!)

FORM 1 (Please put your name and section number (001/10am or 002/2pm) on the scantron!!!!) CS 161 Exam II: True (A)/False(B) (2 pts each):

Exercise 1.1 Hello world

pointers + memory double x; string a; int x; main overhead int y; main overhead

CSC 1300 Exam 4 Comprehensive-ish and Structs

1) You want to determine whether time has run out. The following code correctly implements this:

FORM 2 (Please put your name and form # on the scantron!!!!) CS 161 Exam II:

Lab 2: Pointers. //declare a pointer variable ptr1 pointing to x. //change the value of x to 10 through ptr1

Week 3: Pointers (Part 2)

Introduction to Computer Science Midterm 3 Fall, Points

C++ Basics. Data Processing Course, I. Hrivnacova, IPN Orsay

C++ For Science and Engineering Lecture 15

Week 3. Function Definitions. Example: Function. Function Call, Return Statement. Functions & Arrays. Gaddis: Chapters 6 and 7.

Lecture 23: Pointer Arithmetic

Chapter 9: Pointers Co C pyr py igh i t gh Pear ea so s n n E ducat ca io i n, n Inc. n c.

VARIABLES & ASSIGNMENTS

CSCE 206: Structured Programming in C++

CSCE 206: Structured Programming in C++

BITG 1113: Function (Part 2) LECTURE 5

Chapter 6: User-Defined Functions. Objectives (cont d.) Objectives. Introduction. Predefined Functions 12/2/2016

Basic memory model Using functions Writing functions. Basics Prototypes Parameters Return types Functions and memory Names and namespaces

The American University in Cairo Department of Computer Science & Engineering CSCI &09 Dr. KHALIL Exam-I Fall 2011

CS1500 Algorithms and Data Structures for Engineering, FALL Virgil Pavlu, Jose Annunziato,

GE U111 Engineering Problem Solving & Computation Lecture 6 February 2, 2004

Pointers, Arrays and C-Strings

BITG 1233: Array (Part 1) LECTURE 8 (Sem 2, 17/18)

CSC 126 FINAL EXAMINATION Spring Total Possible TOTAL 100

Review: Exam 1. Your First C++ Program. Declaration Statements. Tells the compiler. Examples of declaration statements

CSc Introduction to Computing

UNIT- 3 Introduction to C++

CS2141 Software Development using C/C++ C++ Basics

Arrays. Week 4. Assylbek Jumagaliyev

CMSC 202 Midterm Exam 1 Fall 2015

1- Write a single C++ statement that: A. Calculates the sum of the two integrates 11 and 12 and outputs the sum to the consol.

! Pass by value: when an argument is passed to a. ! It is implemented using variable initialization. ! Changes to the parameter in the function body

Objectives. Chapter 2: Basic Elements of C++ Introduction. Objectives (cont d.) A C++ Program (cont d.) A C++ Program

Chapter 2: Basic Elements of C++

Output of sample program: Size of a short is 2 Size of a int is 4 Size of a double is 8

6.096 Introduction to C++ January (IAP) 2009

Pointers. Variable Declaration. Chapter 10

Chapter 2: Basic Elements of C++ Objectives. Objectives (cont d.) A C++ Program. Introduction

(6) The specification of a name with its type in a program. (7) Some memory that holds a value of a given type.

Integer Data Types. Data Type. Data Types. int, short int, long int

Basic program The following is a basic program in C++; Basic C++ Source Code Compiler Object Code Linker (with libraries) Executable

Learning Objectives. Introduction to Arrays. Arrays in Functions. Programming with Arrays. Multidimensional Arrays

A First Program - Greeting.cpp

Multiple Choice (Questions 1 13) 26 Points Select all correct answers (multiple correct answers are possible)

Understanding main() function Input/Output Streams

What we will learn about this week: Declaring and referencing arrays. arrays as function arguments. Arrays

CMPS 221 Sample Final

CMSC 202 Section 010x Spring Justin Martineau, Tuesday 11:30am

The American University in Cairo Department of Computer Science & Engineeringt CSCI &09 Dr. KHALIL Exam-I Fall 2009

CSC 126 FINAL EXAMINATION FINAL Spring 2012 B. Name (last, First) Instructor. Total Possible. Received

Agenda. The main body and cout. Fundamental data types. Declarations and definitions. Control structures

CS Spring 05 - MidTerm

UEE1302 (1102) F10 Introduction to Computers and Programming (I)

Outline. Introduction. Arrays declarations and initialization. Const variables. Character arrays. Static arrays. Examples.

Pointer Data Type and Pointer Variables

Total 100. The American University in Cairo Computer Science & Engineering Department CSCE 106. Instructor: Final Exam Fall Section No.

Functions, Arrays & Structs

Week 3. Function Definitions. Example: Function. Function Call, Return Statement. Functions & Arrays. Gaddis: Chapters 6 and 7. CS 5301 Spring 2018

Programming Language. Functions. Eng. Anis Nazer First Semester

CSCE 110 PROGRAMMING FUNDAMENTALS

CMSC202 Computer Science II for Majors

Implementing an ADT with a Class

CSC 307 DATA STRUCTURES AND ALGORITHM ANALYSIS IN C++ SPRING 2011

Total 100. The American University in Cairo Computer Science & Engineering Department CSCE 106. Dr. Khalil Exam II Fall 2011

Chapter 17 - Notes Recursion

FORM 1 (Please put your name and form # on the scantron!!!!) CS 161 Exam I: True (A)/False(B) (2 pts each):

5. Assuming gooddata is a Boolean variable, the following two tests are logically equivalent. if (gooddata == false) if (!

Input And Output of C++

CSCE 110 PROGRAMMING FUNDAMENTALS

Pointers and Strings. Adhi Harmoko S, M.Komp

BITG 1113: Array (Part 1) LECTURE 8

Exam 2. CSI 201: Computer Science 1 Fall 2016 Professors: Shaun Ramsey and Kyle Wilson. Question Points Score Total: 80

C++ Programming: From Problem Analysis to Program Design, Third Edition

BEng (Hons) Electronic Engineering. Resit Examinations for / Semester 1

UEE1302 (1102) F10 Introduction to Computers and Programming (I)

CAAM 420 Fall 2012 Lecture 29. Duncan Eddy

Review. Outline. Array Pointer Object-Oriented Programming. Fall 2013 CISC2200 Yanjun Li 1. Fall 2013 CISC2200 Yanjun Li 2

CS 31 Discussion 1A, Week 8. Zengwen Yuan (zyuan [at] cs.ucla.edu) Humanities A65, Friday 10:00 11:50 a.m.

Review Questions for Final Exam

Using Parallel Arrays. Parallel Array Example

Chapter 1 INTRODUCTION

Review. Outline. Array Pointer Object-Oriented Programming. Fall 2017 CISC2200 Yanjun Li 1. Fall 2017 CISC2200 Yanjun Li 2

1) What of the following sets of values for A, B, C, and D would cause the string "one" to be printed?

Chapter 2. C++ Syntax and Semantics, and the Program Development Process. Dale/Weems 1

CS Introduction to Programming Midterm Exam #2 - Prof. Reed Fall 2015

CSCE Practice Midterm. Data Types

Non-numeric types, boolean types, arithmetic. operators. Comp Sci 1570 Introduction to C++ Non-numeric types. const. Reserved words.

Pointers, Dynamic Data, and Reference Types

CSc Introduc/on to Compu/ng. Lecture 8 Edgardo Molina Fall 2011 City College of New York

Your first C++ program

Dynamic Allocation of Memory

C++ Structures Programming Workshop 2 (CSCI 1061U)

BITG 1233: Introduction to C++

C introduction: part 1

Transcription:

CMPSC11 Final (Study Guide) Fall 11 Prof Hartman Name MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question. 1) This is a collection of statements that performs a specific task. 1) A) function B) constant C) variable D) infinite loop ) A function contains the statements that make up the function. ) A) expression B) definition C) call D) parameter list E) prototype 3) A function can have zero to many parameters, and it can return this many values. 3) A) only one B) no C) zero to many D) a maximum of ten ) In a function header, you must furnish: ) A) data type of the return value B) the name of function C) names of parameter variables D) data type(s) of the parameters E) All of these 1

5) What is the output of the following program? 5) # include <iostream> using namespace std; void dosomething(int&); int main( ) int x = ; dosomething(x); return ; void dosomething(int& num) num = ; cout << num << endl; A) B) C) D) 6) Look at the following function prototype. 6) int myfunction(double); What is the data type of the funtion's parameter variable? A) double B) void C) int D) can't tell from the prototype 7) Which of the following is a valid C++ array definition? 7) A) int array[1]; B) void numbers[5]; C) float $payments[1]; D) int array[]; 8) What is the last legal subscript that can be used with the following array? 8) int values[5]; A) 5 B) 6 C) D)

9) What will the following code display? 9) int numbers[ ] = 99, 87, 66, 55, 11 ; for (int i = 1; i < ; i++) cout << numbers[i] << endl; A) 99 87 66 55 11 C) 87 66 55 11 B) 87 66 55 D) Nothing. This code has an error. 1) A algorithm is a method of locating a specific item of information in a larger collection of data. A) sort B) standard C) linear D) search 11) What will the following code display? 1) 11) int numbers[ ] = 99, 87, 66, 55, 11 ; cout << numbers[3] << endl; A) 66 B) 87 C) 55 D) 11 1) A(n) search is more efficient than a(n) search 1) A) binary, linear B) character, string C) integer, double D) linear, binary 13) A binary search begins with the element of an array. 13) A) first B) largest C) last D) middle 3

1) What is the output of the following code segment? 1) n = 1; for ( ; n <= 5; ) cout << n << ' '; n++; A) 1 3 B) 1 3 5 C) 1 1 1... and on forever D) 3 5 6 E) 3 5 15) What will the following loop display? 15) int x = ; while (x < 5) x++; A) 1 3 B) 1 3 5 C) 1 3 D) The loop will display numbers starting at, for infinity. 16) What will the following code display? 16) int x = ; for (int count = ; count < 3; count++) x += count; A) 6 B) C) 1 D) 3

17) How many times will the following loop display "Hello"? 17) for (int i = ; i > ; i--) cout << "Hello!" << endl; A) 19 B) 1 C) D) an infinite number of times 18) The statement int *ptr = new int; 18) A) assigns an integer less than 3767 to the variable named ptr B) creates a new pointer named int C) assigns an address to the variable named ptr D) results in a compiler error 19) Every byte in the computer's memory is assigned a unique: 19) A) address B) pointer C) dynamic allocation D) name ) What will the following code output? ) int number = ; int *var = &number; cout << *var << endl; A) an asterisk followed by B) an asterisk followed by the address of the number variable C) the address of the number variable D) 1) What will the following code output? 1) int number = ; int *var = &number; cout << var << endl; A) the address of the number variable B) C) an asterisk followed by the address of the number variable D) an asterisk followed by 5

) Look at the following code. ) int numbers[ ] =, 1,, 3, ; int *ptr = numbers; ptr++; After this code executes, which of the following statements is true? A) ptr will hold the address of numbers[] B) ptr will hold the address of numbers[1] C) ptr will hold the address of the nd byte within the element numbers[] D) This code will not compile. 3) When this is placed in front of a variable name, it returns the address of that variable. 3) A) conditional operator B) ampersand ( & ) C) semicolon ( ; ) D) asterisk ( * ) ) What does the following statement do? ) double *num; A) declares a double variable named num B) initializes a variable named *num C) declares and initializes an pointer variable named num D) declares a pointer variable named num 5) These can be used as pointers. 5) A) Array names B) Punctuation marks C) Numeric constants D) All of these 6) The, also known as the address operator, returns the memory address of a variable. 6) A) ampersand ( & ) B) percent sign (%) C) asterisk ( * ) D) exclamation point (! ) 7) algorithms are used to arrange random data into some order. 7) A) Linear B) Sorting C) Standard search D) Binary search 6

8) What will the following code do? 8) const int SIZE = 5; double x[size]; for(int i = ; i <= SIZE; i++) x[i] =.; A) Each element in the array, except the first, is initialized to.. B) Each element in the array is initialized to.. C) Each element in the array, except the first and the last, is initialized to.. D) An error will occur when the code runs. 9) What is the output of the following program? 9) # include <iostream> using namespace std; int getvalue(int); int main( ) int x = ; cout << getvalue(x) << endl; return ; int getvalue(int num) return num + 5; A) 7 B) C) 5 D) "getvalue(x)" 7

3) Which line in the following program contains the prototype for the showdub function? 3) 1 # include <iostream> using namespace std; 3 void showdub(int); 5 6 int main( ) 7 8 int x = ; 9 1 showdub(x); 11 1 return ; 13 1 15 void showdub(int num) 16 17 cout << (num * ) << endl; 18 A) 1 B) C) 15 D) 6 31) What is the output of the following program? 31) # include <iostream> using namespace std; void dosomething(int); int main( ) int x = ; dosomething(x); return ; void dosomething(int num) num = ; cout << num << endl; A) B) C) D) 8

3) What is the output of the following program? 3) # include <iostream> using namespace std; void showdub(int); int main( ) int x = ; showdub(x); return ; void showdub(int num) cout << (num * ) << endl; A) B) C) D) 33) Given the following function definition 33) void calc (int a, int& b) int c; c = a + ; a = a * 3; b = c + a; What is the output of the following code fragment that invokes calc? (All variables are of type int) x = 1; y = ; z = 3; calc(x, y); cout << x << " " << y << " " << z << endl; A) 1 1 9 B) 1 6 3 C) 3 6 3 D) 1 3 9