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

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

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

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

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

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

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

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

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

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!

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

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

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

EECS 183 Winter 2016 Exam 2

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?

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

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

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

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

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

a. a * c - 10 = b. a % b + (a * d) + 7 =

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

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

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

Ch 6. Functions. Example: function calls function

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

Do not start the test until instructed to do so!

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

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

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

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

CS 111X - Fall Test 1

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

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

CSCE 206: Structured Programming in C++

Sample Code: OUTPUT Daily Highs & Lows

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

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

CSCE 206: Structured Programming in C++

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

Summary of basic C++-commands

CSCI 102L - Data Structures Midterm Exam #1 Fall 2011

Week 4 EECS 183 MAXIM ALEKSA. maximal.io

Problem Solving: Storyboards for User Interaction

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

CMSC 202 Midterm Exam 1 Fall 2015

To become familiar with array manipulation, searching, and sorting.

CS101 PLEDGED SPRING 2001

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

Spring 2002 Page 1 of 8 READ THIS NOW!

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

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

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

Unit 6. Thinking with Functions

C++ Final Exam 2017/2018

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

Computer Science II Lecture 1 Introduction and Background

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

Introduction to Computer Science Midterm 3 Fall, Points

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

CSCE 110 PROGRAMMING FUNDAMENTALS

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

Name: University of Michigan uniqname: (NOT your student ID number!)

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

Free Response (110 Points)

CSC 126 FINAL EXAMINATION Spring Total Possible TOTAL 100

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

Chapter 2 C++ Fundamentals

Engineering Problem Solving with C++, Etter/Ingber

Getting started with C++ (Part 2)

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

Chapter 2: Overview of C++

CSCE Practice Midterm. Data Types

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

Wentworth Institute of Technology COMP201 Computer Science II Spring 2015 Derbinsky. C++ Kitchen Sink. Lecture 14.

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

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

ECE 462 Fall 2011, Second Exam

(the bubble footer is automatically inserted into this space)

CSC 222: Computer Programming II. Spring 2004

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

Introduction to Programming

CS 1044 Project 1 Fall 2011

Note: The buy help from the TA for points will apply on this exam as well, so please read that carefully.

As an example using arrays, let s write some code to get started with the Upthrust game. We can use a 2D array to represent the game board.

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

Programming Language. Functions. Eng. Anis Nazer First Semester

Definition Matching (10 Points)

Midterm Practice Exam

Functions that Return a Value. Approximate completion time Pre-lab Reading Assignment 20 min. 92

CS 1301 Exam 1 Fall 2010

switch case Logic Syntax Basics Functionality Rules Nested switch switch case Comp Sci 1570 Introduction to C++

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

CS 115 Exam 3, Spring 2011

Review. Modules. CS 151 Review #6. Sample Program 6.1a:

Sample Final Exam. 1) (24 points) Show what is printed by the following segments of code (assume all appropriate header files, etc.

Chapter 2: Basic Elements of C++

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

Transcription:

University of Michigan EECS 183: Elem. Programming Concepts Fall 2011 Exam 1: Part 1: Form 1 Professors: ML Dorf, Elliot Soloway Wed 9- February- 2011 35 questions * 3 pts each = 105 pts (yes we know there are 37 questions) Instructions Bubble in your name, UMID, AND FORM on scantron sheet. 'section' is not needed. This course operates under the rules of the college of Engineering Honor Code. Your signature endorses the pledge below. After you finish your exam, sign the scantron sheet to indicate you have adhered to the Honor Pledge. The exam is closed book. No books, notes or the like may be used. This exam is closed electronic devices. No computers, calculators, PDAs, cell phones or other electronic devices may be used. I know texting is a good thing just not during an exam. The exam is closed neighbor. No 'partner' on this - - only on projects - - NO talking with other students during the exam. NO sign languages. NO passing notes. NO communication of any type or form. Some questions are not simple, therefore, read carefully Assume all code and code fragments compile, unless otherwise specified. Assume/use only the standard ISO/ANSI C++. Assume "valid" means compiles and runs in standard ISO/ANSI C++ Honor Pledge: "I have neither given nor received aid on this exam, nor have I concealed any violations of the Honor Code." Fall 2010 Page 1 of 11

Basics 1. Which of these has the highest precedence? A. / B. % C. + D. * E. () 2. Which of these has the lowest precedence priority? A. B. + C. * D. I don t know E.! 3. What prints? (Think carefully) double x = 1000 * 1000 * 1000 * 4 * 0.5; cout << x << endl; A. 2000000000 B. 2000000000.0000 C. 2E09 D. cannot be determined E. multiple of the above are correct 4. What will be the result of 100/10*2? A. Other B. I don t know C. 5 D. 20 5. What will be the results of 1000 / 100 % 7 * 2? A. Other B. 10 C. 6 D. 250 E. 1000 6. What does this C++ expression ( 5 / 2 ) * 4 evaluate to? A. 0 B. 2 C. 8 D. 10 Fall 2010 Page 2 of 11

7. What does this C++ expression ( 5 / 2 ) * 4.0 evaluate to? A. 0.0 B. 2.0 C. 8.0 D. 10.0 8. Why is using named constants important in programming? A. to create self-documenting code B. to make the program more maintainable C. to make debugging easier D. all of the above 9. What do you need to #include to be able to use int x = 0; cout << x + 5 << endl; A. #include <iostream> B. #include <cmath> C. #include <string> D. #include <iomanip> 10. What do you need to #include to be able to use: int x = 0; x = x * 5-7.2 / 3; A. #include <iostream> B. #include <cmath> C. #include <string> D. #include <iomanip> 11. In C++, which of the following is NOT an operator A.!= B. ++ C. cin D. / E. All the above are operators Fall 2010 Page 3 of 11

12. Given a bool variable isfull, which of the following is a valid C++ assignment statement? A. isfull = true; B. isfull = isfull ceil(2.4) % 2 + 1 == 3; C. isfull = 2 < 3 + 2 < 20-5; D. all of the above 13. Which of the following code fragments outputs the number 3 to the screen? A. cout << 1 + 2 * 3 / 4 << endl; B. cout << 1 * 2 + 3 / 4 + 2 << endl; C. cout << 2 * (2 + 3) / 4 << endl; D. cout << 1 / 2 * 2 + 3 << endl; E. More than one of the above 14. Consider the following code fragment: int x = 0, y = 0, z = 0; char ch; cin >> x >> ch >> y >> ch >> z >> ch; cout << x + y + z; If the user types 2.5 + 3-10 and presses return at the standard input, what does the above code fragment print? A. 0 B. 7 C. 8 D. 10 E. None of the above 15. What is the output when the following code fragment is executed? int n; double x = 3.8; n = (int)x; cout << n << endl; A. 3 B. 4 C. 8 D. this will not compile 16. Which of the following is a valid function prototype? Fall 2010 Page 4 of 11

A. float some Function(); B. void nothing; C. int (int thing); D. void something(); 17. Given the prototype: void foo(int x); which of the following calls are valid. Select all choices that apply. A. cout << foo(42); B. int y = foo(15); C. foo(-5); D. int y = 5 + foo(6); 18. Which of the following is equivalent to (!(p < q) )? A. p < q B. p >= q C. p > q D.!p >=! q 19. Can a return statement be used in a void function? A. Yes, and it will return where it was called from B. Yes, and the return statement will be ignored C. No D. Depends 20. What is the output of this line of code, given the following definition? cout << anumber(2,5); // code in main int anumber (int x, int y) // function definition return (2 * x - y); A. -6 B. -1 C. 6 D. 8 Fall 2010 Page 5 of 11

21. What is the output of the following line of code, given the function definition that follows: cout << calc (1,2) + calc(2,3); // code in main int calc (int x, int y) x = x + 1; return x % y; // function definition A. 0 B. 1 C. 2 D. none of the above 22. Which of the following function calls is valid for the function prototype? void calculation (int m, char p, double q); A. cout << calculation (3, "y", 2.0); B. cout << calculation (10, 'r', 7); C. calculation (10, 'r', 7.5); D. two of the above 23. Consider the following function definition: int truncate(double bigandugly) int smallandpretty = static_cast<int>(bigandugly); return smallandpretty; Which of the following is/are valid calls to this function: A. double value = truncate(44.5); B. int value = truncate(5); C. truncate(5.0); D. all the above Fall 2010 Page 6 of 11

24. What is the output of the following line of code, given the function definition that follows: cout << calc (calc(2,3),2); // code in main int calc (int x, int y) x = x + 1; return x % y; A. 0 B. 1 C. 2 D. none of the above 25. What value gets printed by the program? #include <iostream> using namespace std; int foo(int x, int y); int bar(int x, int y); int main( ) const int x = 3; const int y = 2; cout << bar(x,y) << endl; return 0; int foo(int x, int y) return x+y; int bar(int x, int y) return foo(x, y) +1; A. 3 B. 5 C. 6 D. Ill-formed will not compile E. Un-defined Fall 2010 Page 7 of 11

26. Given the following code fragment, what prints? Yes we know there are no int x = 5; if ( ( x!= 0 ) && ( 10 / x == 2 ) ) cout << "HERE"; else cout << "THERE"; A. HERE B. THERE C. the above code causes a division by zero error D. none of the above 27. Given the following code fragment, what prints? Yes we know there are no int x = 0; if ( ( x!= 0 ) && ( 10 / x == 2 ) ) cout << "HERE"; else cout << "THERE"; A. HERE B. THERE C. the above code causes a division by zero error D. none of the above 28. What value gets printed by the program? #include <iostream> int main( ) int x = 0; int y = 0; if (x++ && y++) y += 2; cout << x + y << endl; return 0; A. 1 B. 2 C. 3 D. 4 E. Undefined Fall 2010 Page 8 of 11

The following code fragment applies to the next 2 questions: What is the output of the following code: if (age < 5) cout << You will attend kindergarten soon. << endl; else if (age > 10) cout << You are in elementary school. << endl; else if (age < 15) cout << Congrats you are in middle school. << endl; else if (age < 18) cout << Almost there... << endl; else cout << Go BLUE! << endl; 29. What is the output if the age variable is 15? A. You will attend kindergarten soon. B. You are in elementary school. C. Congrats you are in middle school. D. Almost there... E. GO BLUE! 30. What if the age variable is 10? A. You will attend kindergarten soon. B. You are in elementary school. C. Congrats you are in middle school. D. Almost there... E. GO BLUE! 31. If we have: ( Yes we know there are no ) int foo(int x) if(x>2) return x + foo(x-1); else return 0; What will be the result of: cout << foo(3) << endl; A. Program will freeze B. 6 C. 3 D. 10 E. 0 Fall 2010 Page 9 of 11

For the next 2 questions you are given: (Yes we know there are no ) if (n < 10) if (n > 0) cout << "HERE" << endl; else cout << "THERE" << endl; cout << "I'm LOST" << endl; cout << "GO BLUE!" << endl; 32. What is the first line output if the variable n has the value 7? A. HERE B. THERE C. I'm LOST D. GO BLUE! 33. What is the first line output if the variable n has the value of 15? A. HERE B. THERE C. I'm LOST D. GO BLUE! 34. Consider the following function: int difference(int x, int y) if ( x > y ) return x - y; else if ( x < y ) return y - x; else return 0; Which of the following test suites thoroughly tests the above function by testing every path through the function? A. (1,-1), (2,-2), (3,-3) B. (0, 0), (0, 1), (0, 2) C. (1, 1), (1, 2), (2, 1) Fall 2010 Page 10 of 11

35. Consider the following C++ function: int max(int x, int y, int z) if ( x > y && x > z ) return x; else if ( y > x && y > z ) return y; else return z; What does the C++ expression max(1,2,3) + max(20,20,10) evaluate to? A. 23 B. 22 C. 21 D. none of the above 36. Consider the following code fragment: int x = 7; if ( x == 7 / 2 * 2 ) cout << 'a'; cout << 'b'; cout << 'c'; What does the above code print? Read carefully! A. abc B. bc C. c D. 'c' 37. Consider the following code fragment: double x = 7; if ( x = 7 / 2 * 2 ) cout << 'A'; else cout << 'B'; What does the above code print? Read carefully! A. A B. B C. 'A' D. 'B' Fall 2010 Page 11 of 11