Multiple Choice Questions (20 questions * 5 points per question = 100 points)

Similar documents
Multiple Choice Questions (20 questions * 6 points per question = 120 points)

University of Michigan EECS 183: Elem. Programming Concepts Fall 2011 Exam 1: Part 1: Form 1. Professors: ML Dorf, Elliot Soloway

Part 1 (80 points) Multiple Choice Questions (20 questions * 4 points per question = 80 points)

EECS 183 Winter 2016 Exam 2

EECS 183 Fall 2015 Exam 2 Free Response (134 points)

Free Response (110 Points)

CSCE 206: Structured Programming in C++

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.

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 (!

Exam 1. CSI 201: Computer Science 1 Fall 2018 Professors: Shaun Ramsey

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

Do not start the test until instructed to do so!

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

Multiple Choice (Questions 1 14) 28 Points Select all correct answers (multiple correct answers are possible)

EECS 183, Week 5. General. Variables I/O. 0. At which location do you have to take the exam? 1. Source code vs. object code? 2. What s a library?

READ THIS NOW! Do not start the test until instructed to do so!

READ THIS NOW! Failure to read and follow the instructions below may result in severe penalties. Do not start the test until instructed to do so!

CSCE Practice Midterm. Data Types

CS 216 Fall 2007 Midterm 1 Page 1 of 10 Name: ID:

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

CSCE 206: Structured Programming in C++

CSCE 206: Structured Programming in C++

CSCS 261 Programming Concepts Exam 1 Fall EXAM 1 VERSION 1 Fall Points. Absolutely no electronic devices may be used during this exam.

Multiple Choice (Questions 1 14) 28 Points Select all correct answers (multiple correct answers are possible)

Jordan University of Science & Technology Department of Computer Science CS 211 Exam #1 (23/10/2010) -- Form A

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

The American University in Cairo Computer Science & Engineering Department CSCE Dr. KHALIL Exam II Spring 2010

Introduction to Computer Science Midterm 3 Fall, Points

CSCE 206: Structured Programming in C++

CSCE 206: Structured Programming in C++

CS101 PLEDGED SPRING 2001

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

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

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

CSC 126 FINAL EXAMINATION Spring Total Possible TOTAL 100

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

CPE 112 Spring 2015 Exam II (100 pts) March 4, Definition Matching (8 Points)

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

CS 1044 Programming in C++ Test 1 READ THIS NOW! Failure to read and follow the instructions below may result in severe penalties.

CSCE Practice Midterm. Data Types

CMSC 202 Midterm Exam 1 Fall 2015

Exam 1 Practice CSE 232 Summer 2018 (1) DO NOT OPEN YOUR EXAM BOOKLET UNTIL YOU HAVE BEEN TOLD TO BEGIN.

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

CS 111X - Fall Test 1

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

#include <iostream> #include <algorithm> #include <cmath> using namespace std; int f1(int x, int y) { return (double)(x/y); }

Functions. CS111 Lab Queens College, CUNY Instructor: Kent Chin

Definition Matching (10 Points)

1. Which of the following best describes the situation after Line 1 has been executed?

Review Summer CSC1322 Adv Programming in C++ Professor: Zhang

The American University in Cairo Computer Science & Engineering Department CSCE 106 Fundamentals of Computer Science. Instructor: Final Exam Fall 2011

CSC 309/404 Section 901/910 Spring 2017 Midterm Exam Due: May 7 (Sun) 2015, 11:59 pm

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

Spring 2002 Page 1 of 8 READ THIS NOW!

CSCE 2004 Midterm Exam Spring 2017

Chapter void Test( int, int, int ); // Function prototype int main() // Function heading { int h; // Local variable

CPE 112 Spring 2015 Exam III (100 pts) April 8, True or False (12 Points)

Midterm Practice Exam

Do not turn to the next page until the start of the exam.

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

CPE Summer 2015 Exam I (150 pts) June 18, 2015

Increment and the While. Class 15

Today in CS161. Lecture #7. Learn about. Rewrite our First Program. Create new Graphics Demos. If and else statements. Using if and else statements

Due Date: See Blackboard

do { statements } while (condition);

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):

Building on the foundation. Now that we know a little about cout cin math operators boolean operators making decisions using if statements

Name SECTION: 12:45 2:20. True or False (12 Points)

Name. CPTR246 Spring '17 (100 total points) Exam 2

True or False (15 Points)

CS Introduction to Programming Midterm Exam #1 - Prof. Reed Spring 03

(the bubble footer is automatically inserted into this space)

The American University in Cairo Computer Science & Engineering Department CSCE 106 Fundamentals of Computer Science

CS 111X - Fall Test 1 - KEY KEY KEY KEY KEY KEY KEY

True or False (12 Points)

CSCS 261 Programming Concepts Exam 2 Fall EXAM 2 VERSION 1 Fall Points. Absolutely no electronic devices may be used during this exam.

True or False (14 Points)

double d0, d1, d2, d3; double * dp = new double[4]; double da[4];

CSCS 261 Programming Concepts Exam 2 Fall EXAM 2 VERSION 1 Fall Points. Absolutely no electronic devices may be used during this exam.

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

o Counter and sentinel controlled loops o Formatting output o Type casting o Top-down, stepwise refinement

Exceptions, Case Study-Exception handling in C++.

The American University in Cairo Computer Science & Engineering Department CSCE 106 Fundamentals of Computer Science

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

CS 2150 Exam 1, Spring 2018 Page 1 of 6 UVa userid:

CS242 COMPUTER PROGRAMMING

CS 117 Programming II, Spring 2018 Dr. Ghriga. Midterm Exam Estimated Time: 2 hours. March 21, DUE DATE: March 28, 2018 at 12:00 PM

Ch 8. Searching and Sorting Arrays Part 1. Definitions of Search and Sort

Programming Language. Functions. Eng. Anis Nazer First Semester


C++ Final Exam 2017/2018

CSE143 Exam with answers MIDTERM #1, 1/26/2001 Problem numbering may differ from the test as given.

1. a) What #include statement do you put at the top of a program that does uses cin, cout or endl?

CS 115 Exam 3, Spring 2010

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

Linked List using a Sentinel

Solving a 2D Maze. const int WIDTH = 10; const int HEIGHT = 10;

University of Illinois at Urbana-Champaign Department of Computer Science. First Examination

Pointers, Dynamic Data, and Reference Types

Transcription:

EECS 183 Winter 2014 Exam 1 Closed Book Closed Notes Closed Electronic Devices Closed Neighbor Turn off Your Cell Phones We will confiscate all electronic devices that we see including cell phones, calculators, etc. Multiple Choice Questions (20 questions * 5 points per question = 100 points) Key 1 Instructions: Read Carefully! 1. You may have one personally handwritten 3 x 5 notecard. 2. Some questions are not simple, therefore, read carefully. 3. Assume all code and code fragments are syntactically valid, unless otherwise specified. 4. Assume/use only the standard C++11. 5. In all the given code, if any character looks like a space, it is one. 6. On the scantron sheet, bubble in your name and UMID - - 10 pts off for incorrect UMID. 7. On the scantron sheet, bubble in Key 1 - - zero on exam if key not bubbled in. 8. Sign below and print your uniqname - - 10 pts off if we cannot read your uniqname I have neither given nor received aid on this examination, nor have I concealed any violations of the Honor Code. 1

(Intentionally left blank such that you may use if needed) 2

1 What does the following expression evaluate to? 5 / 3 * 3 A) 0 B) 3 C) 5 D) None of the above 2 Which of the following evaluates to an odd number? A) 3 * 6 / 2 / 2 B) 6 * 3 / 2 / 2 C) 6 / 2 / 3 * 2 D) 6 / 3 * 3 / 2 3 Which of the following code fragments will assign the number 4.5 to variable y? A) double y = 2.0 + 5 % 2; B) double y = 2 + 5 / 2; C) double y = 2.0 + 5 / 2; D) double y = 2.0 + 1.0 * 5 / 2; E) double y = 2.0 + 5 / 1.0 * 2; 4 What does the expression 1234 / 10 / 10 % 10 evaluate to? A) 1 B) 2 C) 3 D) 4 3

5 If the user types: 2.5 # 3.5 <enter>, what does the following code snippet output? double x = 3; int y = 2; char ch = '6'; cin >> x >> ch >> y; cout << x * y; A) 5.5 B) 6 C) 7 D) 7.5 6 If the user types: 2.5 # 3.5 <enter>, what does the following code snippet output? (Note: this is a different question than the one above - - really it is - - read closely) double x = 3; int y = 2; char ch = '6'; cin >> y >> x >> ch; cout << x * y; A) 0 B) 1 C) 2 D) 2.5 7 If the user types: Go Blue <enter>, what does the following code snippet output? string str; getline(cin, str); cout << str; A) Go B) Blue C) G D) Go Blue 4

8 Consider the following function: bool iscoronationday(int num) { if (num % 100 == 0) { if (num % 400 == 0) { return true; else { return false; else if (num % 4 == 0) { return true; else { return false; Which of the following test suites thoroughly test the above function by testing every path through the function? A) 1999, 2000, 2001 B) 1899, 1900, 1901, 1902 C) 1800, 2000, 2008 D) 1900, 1930, 1960, 2000 9 What does the following line of code print? cout << "\"//Some people are /";//"worth melting for - - Olaf"; A) \ B) " C) "//Some people are / D) None of the above E) Compilation Error 10 Consider the following C++ function: int oaken(int x) { return x + 1; What does the expression oaken(oaken(3)) evaluate to? A) 3 B) 4 C) 5 D) 6 5

11 What does the following code print? #include <iostream> using namespace std; int kristoff(int x); int anna(int x); int main() { cout << kristoff(1) + anna(2); return 0; int kristoff(int x) { ++x; return anna(x); int anna(int x) { x = x + 2; return x; A) 5 B) 6 C) 7 D) 8 E) 9 12 Which of the following calls to the function frozen are valid (i.e., will compile), if frozen has the function prototype: void frozen(int x, char y); A) frozen(1, '*'); B) cout << frozen(1, '*'); C) int x = frozen(10, '*') + 3; D) All of the above E) A and B 6

13 What does the following C++ program print? #include <iostream> using namespace std; void olaf(int x, int y); int main() { int x = 1; int y = 3; olaf(x, y); cout << x << ", " << y; return 0; void olaf(int x, int y) { int temp = x; x = y; y = temp; return; A) 1, 1 B) 1, 3 C) 3, 1 D) 3, 3 14 What does the following code fragment print if the user enters: - 5 12<enter> int temperature, amount; cin >> temperature >> amount; if (temperature > 0) { if (amount >= 10) { cout << "Build me a friend" << endl; else { cout << "Oh no! It's too cold to snow" << endl; A) Build me a friend B) Oh no! It's too cold to snow C) None of the above 7

15 What does the following C++ program print? #include <iostream> using namespace std; int main() { int x = 42; if (x >= 0) { cout << "I don't have a skull. Or bones."; else if (x <= 42) { cout << "I'm Olaf and I like warm hugs."; else { cout << "It's so cute. Like little baby unicorn"; return 0; cout << "Oh, look at that. I've been impaled."; A) I don't have a skull. Or bones. B) I'm Olaf and I like warm hugs. C) It's so cute. Like little baby unicorn D) Oh, look at that. I've been impaled. E) It will run with no errors, but print nothing. 16 Consider the following function marshmallow: int marshmallow(bool p, bool q) { int x = 0; int y = 2; return ((x > 1) p) && ((y < 3) q); What does the function marshmallow return? A) 0 B) 1 C) The return value depends on the values of both p and q D) The return value depends on the value of p but not q E) The return value depends on the value of q but not p 8

17 What does the following code snippet print? int x = 1; while (x < 5) { x *= x + 1; cout << x << " "; A) 1 B) 5 C) 6 D) 1 2 6 E) 2 6 18 Given the following function implementation, what does bulda(5) return? int bulda(int n) { int i = 0; while (i < n) { i = i + 1; n = n + 1; return i; A) 4 B) 5 C) 6 D) Behavior is undefined - - may or may not stop 9

19 If the user types 20 60 0 70 <enter> what does the following code print? int x; int sven = 0; cin >> x; while (x > 0) { if (x > sven) { sven = x; cin >> x; cout << sven ; A) 20 B) 60 C) 0 D) 70 20 Which of the following is a complement of the C++ expression (temperature < 10 temperature > 80)? A) (temperature > 10 && temperature < 80) B) (10 <= temperature <= 80) C) (10 <= temperature && temperature <= 80) D) (temperature >= 10 temperature <= 80) 10