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

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

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

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

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

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

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

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

Chapter Five: Functions. by Cay Horstmann Copyright 2018 by John Wiley & Sons. All rights reserved

Week 4 EECS 183 MAXIM ALEKSA. maximal.io

CS 1044 Project 1 Fall 2011

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

Discussion 1H Notes (Week 3, April 14) TA: Brian Choi Section Webpage:

CSCE 206: Structured Programming in C++

CSCI 111 Midterm 1, version A Exam Fall Solutions 09.00am 09.50am, Tuesday, October 13, 2015

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

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.

CSCI 111 First Midterm Exam Fall Solutions 09.00am 09.50am, Wednesday, October 18, 2017

C++ PROGRAMMING. For Industrial And Electrical Engineering Instructor: Ruba A. Salamh

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

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

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

Programming in C++ Prof. Partha Pratim Das Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur

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

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

Computer Programming

Introduction to Programming I COS1511 School of Computing Revision Notes

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

Concepts Review. 2. A program is the implementation of an algorithm in a particular computer language, like C and C++.

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

Programming Language. Functions. Eng. Anis Nazer First Semester

CSCE 206: Structured Programming in C++

CSCE 206: Structured Programming in C++

CSCE 121 ENGR 112 List of Topics for Exam 1

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

Module 10A Lecture - 20 What is a function? Why use functions Example: power (base, n)

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

VARIABLES & ASSIGNMENTS

EE 109 Lab 8a Conversion Experience

CSCE Practice Midterm. Data Types

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?

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

Structured Programming Using C++ Lecture 2 : Introduction to the C++ Language. Dr. Amal Khalifa. Lecture Contents:

CS 101 Spring 2007 Midterm 2 Name: ID:

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

Increment and the While. Class 15

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

Computer Department. Question (1): State whether each of the following is true or false. Question (2): Select the correct answer from the following:

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

Unit 7. 'while' Loops

CSC 1300 Exam 4 Comprehensive-ish and Structs

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

Lab 3: Control Flow / Conditional Statements. Based on the presentation made by Graham Northup

Exam 3 Chapters 7 & 9

CSCE Practice Midterm. Data Types

How to approach a computational problem

CMPS 221 Sample Final

PIC 10A Flow control. Ernest Ryu UCLA Mathematics

Overview. - General Data Types - Categories of Words. - Define Before Use. - The Three S s. - End of Statement - My First Program

More Examples Using Functions and Command-Line Arguments in C++ CS 16: Solving Problems with Computers I Lecture #6

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

LAB 4.1 Relational Operators and the if Statement

Engineering Problem Solving with C++, 3e Chapter 2 Test Bank

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

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

Lab 2.1: Fixing a C++ program

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

The C++ Language. Arizona State University 1

6 Functions. 6.1 Focus on Software Engineering: Modular Programming TOPICS. CONCEPT: A program may be broken up into manageable functions.

Chapter 1. C++ Basics. Copyright 2010 Pearson Addison-Wesley. All rights reserved

8. The C++ language, 1. Programming and Algorithms II Degree in Bioinformatics Fall 2017

This watermark does not appear in the registered version - Slide 1

AP Statistics Summer Math Packet

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

Week 2: Console I/O and Operators Arithmetic Operators. Integer Division. Arithmetic Operators. Gaddis: Chapter 3 (2.14,3.1-6,3.9-10,5.

Arrays in C++ Instructor: Andy Abreu

CSCI 102 Fall 2010 Exam #1

Modern C++ for Computer Vision and Image Processing. Igor Bogoslavskyi

Honors Computer Science C++ Mr. Clausen Program 3A, 3B, 3C

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

CS101 PLEDGED SPRING 2001

Final Examination Semester 2 / Year 2005

Add Subtract Multiply Divide

Chapter 17 - Notes Recursion

CSE 131 Introduction to Computer Science Fall 2016 Exam I. Print clearly the following information:

CSci 1113 Final. Name: Student ID:

Help File on C++ and Programming at CSUSM by Rika Yoshii

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!

Your First C++ Program. September 1, 2010

CSci 1113 Midterm 1. Name: Student ID:

15: Polymorphism & Virtual Functions

Homework #3 CS2255 Fall 2012

Kingdom of Saudi Arabia Princes Nora bint Abdul Rahman University College of Computer Since and Information System CS240 BRANCHING STATEMENTS

1. Match each of the following data types with literal constants of that data type. A data type can be used more than once. A.

Notices. Test rules. Page 1 of 8. CS 1112 Spring 2018 Test 2

More Flow Control Functions in C++ CS 16: Solving Problems with Computers I Lecture #4

EECS402 Lecture 02. Functions. Function Prototype

Notes on the 2016 Exam

Practice test for midterm 1

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

University of Dublin

Transcription:

Exam 1 CSI 201: Computer Science 1 Fall 2018 Professors: Shaun Ramsey I understand that this exam is closed books and closed notes and is to be completed without a calculator, phone, or other computer. It is clear that I am cheating or plagiarizing if these items are seen in use by me during the exam. I am NOT allowed to use any external resources to complete this exam. All of the work that I am submitting for this exam is mine. I understand that it is also my job to protect my own answers from others. I understand that I can cheat or plagiarize on an exam by my own collaboration but also through my own negligence (in keeping my answers secret). I have completed this exam in accordance with the Washington College Honor Code. I understand that images, video and sound may be taken and recorded during this exam. Remember to use good style and programming practice throughout. Read directions thoroughly. Name: Signature: Section: Page 1 of 7

1. 20 points Write the output for each code snippet. Each snippet is worth 2 points. Code Snippet: Console Output: int hours = 36; cout << "full " << hours/24 << endl; cout << "left " << hours%24 << endl; for(int i = 0; i < 3; i++) { cout << i * 3 << endl; int number = 11; if(number < 7 number > 13) { cout << "lucky" << endl; else { cout << " not so " << endl; int exponents = 1; while(exponents < 20) { cout << exponents << endl; exponents = exponents * 3; double eps = 0.01; double num = 0.0; if(num < eps && num > -eps) { cout << "close" << endl; else { cout << "eps" << endl; Page 2 of 7

2. Concepts: answer with 1-2 lines of code or briefly as appropriate. (a) 4 points Demonstrate how to declare a variable that represents the name of our school. Initialize it with an appropriate value. (b) 4 points For what values of x does the following code output 1782. if(x > 1782 && x < 2022) { cout << "1782" << endl; (c) 4 points Write a loop that runs 1782 times. (d) 4 points What should the user type into the console to stop the following loop: while(var == "WC") { cout << "QUACK" << endl; cin >> var; (e) 4 points Why do we compile our C++ code? Page 3 of 7

3. 16 points Find four kinds of errors in the following code snippet. Identify each error that you found in the space below. Explicitly explain the error (describe what is missing or incorrect), don t simply write the code where the error exists (unless you re fixing it to point out the error instead of describing the error). There may be more than four errors, but you only need to find four. Do not include duplicate errors. Refer to lines using the given line numbers. /* Code Snippet begins here */ 1. int distance = 0; //displacement 2. int velocity = 0, accel = 0; 3. cin >> velocity >> accel >> t; 4. while(velocity < 0 accel < 0 t < 0) { 5. cout << "ERROR << endl; 6. cin >> velocity >> accel >> t 7. 8. distance == velocity * t + 0.5 * accel * t * t; 9. cout << "Total distance traveled is " distance << endl; /* Code Snippet ends here */ Error 1. Line #: Error 2. Line #: Error 3. Line #: Error 4. Line #: Page 4 of 7

4. 20 points (a) Your room can only hold 100 sq. ft. of furniture. In this code, you ll read in the size of three pieces of furniture and then determine if it will fit within this size. Here are your steps. Write code to read in the size of three pieces of furniture as sq. ft. These numbers may have decimals. When the total sum of these three pieces is within 100 sq. ft. then output to the console that these pieces might fit in the room. Otherwise, output that they will definitely not it. sq. ft. stands for square feet and is a unit of measurement denoting an area. If it helps, you can replace sq. ft. with ft 2 or m 2 as you think about this problem. Also, just because the furniture is less than 100 sq. ft. doesn t mean it will actually fit in the room. If the room is 10 ft. x 10 ft. and the three pieces of furniture have a base of 15 ft. x 1 ft. (only 15 sq. ft. each), then none of the pieces would really fit on the floor of this room. #include <iostream> using namespace std; int main() { // Your code goes here // end of your code return 0; Page 5 of 7

(b) In this problem, your job is to create math problems for elementary school students to practice their mathematics. Here are your steps. Read in a string from the user. Valid values are plus and done. Then get three integers from the user. The first two integers (along with the string) form the question. The last integer is the answer. If the word was plus and the third integer is the sum of the first two integers, then output CORRECT! When the word is plus and the third is not the sum of the first two, output Try again!. Allow the user to re-enter the third integer until the sum is correct. Lastly, get a new string from the user. As long as they continue to type something other than done then, repeat this entire process starting at get three integers from the user. Here is an example. An example input string is: plus 3 2 5 7 5 6 pow pow plus 1 1 2 done This produces the output string: Try again! Try again! Try Again! CORRECT! CORRECT! #include <iostream> #include <string> using namespace std; int main() { // Your code goes here // end of your code return 0; Page 6 of 7

Question Points Score 1 20 2 20 3 16 4 20 Total: 76 Page 7 of 7