CSCE 121 ENGR 112 List of Topics for Exam 1

Similar documents
C++ Support Classes (Data and Variables)

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

PIC 10A Flow control. Ernest Ryu UCLA Mathematics

Programming Language. Functions. Eng. Anis Nazer First Semester

CS31 Discussion 1E. Jie(Jay) Wang Week3 Oct.12

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

Unit 7. 'while' Loops

do { statements } while (condition);

CS 151 Review #3. // More than one variable can be defined // in a statement. Multiple variables are // separated by a comma.

Objectives. In this chapter, you will:

Computer Programming

int n = 10; int sum = 10; while (n > 1) { sum = sum + n; n--; } cout << "The sum of the integers 1 to 10 is " << sum << endl;

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++

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

Chapter 3 Objects, types, and values. Bjarne Stroustrup

Abstract. Chapter 6 Writing a Program. Overview. Writing a program: Strategy. Building a program. Bjarne Stroustrup

Name Section: M/W T/TH Number Definition Matching (8 Points)

Errors. Lecture 6. Hartmut Kaiser hkaiser/fall_2011/csc1254.html

Add Subtract Multiply Divide

5. Control Statements

CAMBRIDGE SCHOOL, NOIDA ASSIGNMENT 1, TOPIC: C++ PROGRAMMING CLASS VIII, COMPUTER SCIENCE

Name Section: M/W T/TH Number Definition Matching (6 Points)

Introduction to Programming using C++

Pace University. Fundamental Concepts of CS121 1

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

Lecture Programming in C++ PART 1. By Assistant Professor Dr. Ali Kattan

STATS 507 Data Analysis in Python. Lecture 2: Functions, Conditionals, Recursion and Iteration

Review Questions I Spring 2010

Chapter 5 Errors. Bjarne Stroustrup

Chapter 5 Errors. Hyunyoung Lee. Based on slides by Bjarne Stroustrup.

Computer Programming : C++

Lab # 02. Basic Elements of C++ _ Part1

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

Getting started with C++ (Part 2)

If Control Construct

Chapter 2 C++ Fundamentals

Chapter 2 Basic Elements of C++

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

Class 14. Input File Streams. Laura Marik Spring 2012 C++ Course Notes (Provided by Jason Minski)

Chapter 4. Computation. Bjarne Stroustrup.

what are strings today: strings strings: output strings: declaring and initializing what are strings and why to use them reading: textbook chapter 8

Chapter 6 Writing a Program

CS 105 Lecture 5 Logical Operators; Switch Statement. Wed, Feb 16, 2011, 5:11 pm

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

Project 1. due date Sunday July 8, 2018, 12:00 noon

CSCE 110 PROGRAMMING FUNDAMENTALS

CSCE 206: Structured Programming in C++

Why Is Repetition Needed?

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

Computer Programming. Basic Control Flow - Loops. Adapted from C++ for Everyone and Big C++ by Cay Horstmann, John Wiley & Sons

Relational Operators and if. Class 10

Chapter 1 INTRODUCTION

BOOLEAN EXPRESSIONS CONTROL FLOW (IF-ELSE) INPUT/OUTPUT. Problem Solving with Computers-I

C++ Programming: From Problem Analysis to Program Design, Fourth Edition. Chapter 5: Control Structures II (Repetition)

Lecture 5: Writing a program

These are notes for the third lecture; if statements and loops.

CS Spring 05 - MidTerm

Programming with C++ as a Second Language

Creating a C++ Program

Lab Instructor : Jean Lai

Chapter 3 Objects, Types, and Values

Computer Programming. Basic Control Flow - Decisions. Adapted from C++ for Everyone and Big C++ by Cay Horstmann, John Wiley & Sons

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

Programming Language. Control Structures: Repetition (while) Eng. Anis Nazer Second Semester

THE INTEGER DATA TYPES. Laura Marik Spring 2012 C++ Course Notes (Provided by Jason Minski)

BITG 1233: Introduction to C++

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

EECS 183. Week 3 - Diana Gage. www-personal.umich.edu/ ~drgage

Chapter 4 Computation

Learning Recursion. Recursion [ Why is it important?] ~7 easy marks in Exam Paper. Step 1. Understand Code. Step 2. Understand Execution

M/s. Managing distributed workloads. Language Reference Manual. Miranda Li (mjl2206) Benjamin Hanser (bwh2124) Mengdi Lin (ml3567)

Object-oriented Programming for Automation & Robotics Carsten Gutwenger LS 11 Algorithm Engineering

Computer Programming

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

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

Language Reference Manual

Arrays in C++ Instructor: Andy Abreu

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

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

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

Chapter 2. C++ Basics. Copyright 2014 Pearson Addison-Wesley. All rights reserved.

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

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

Welcome Back. CSCI 262 Data Structures. Hello, Let s Review. Hello, Let s Review. How to Review 1/9/ Review. Here s a simple C++ program:

ENJOY! Problem 2 What does the following code do, in a brief English sentence? int mystery(int k) { int i = 0; if (k < 0) return -1;

CHAPTER 1.2 INTRODUCTION TO C++ PROGRAMMING. Dr. Shady Yehia Elmashad

Intro to Programming & C Why Program? 1.2 Computer Systems: Hardware and Software. Why Learn to Program?

Outline. Why do we write functions? Introduction to Functions. How do we write functions? Using Functions. Introduction to Functions March 21, 2006

WARM UP LESSONS BARE BASICS

RYERSON POLYTECHNIC UNIVERSITY DEPARTMENT OF MATH, PHYSICS, AND COMPUTER SCIENCE CPS 710 FINAL EXAM FALL 96 INSTRUCTIONS

Boolean Algebra Boolean Algebra

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

Control Structures. Control Structures Conditional Statements COMPUTER PROGRAMMING. Electrical-Electronics Engineering Dept.

Objectives. Chapter 4: Control Structures I (Selection) Objectives (cont d.) Control Structures. Control Structures (cont d.) Relational Operators

Introduction to Programming I COS1511 School of Computing Revision Notes

Lesson 10A OOP Fundamentals. By John B. Owen All rights reserved 2011, revised 2014

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

Chapter 1 Summary. Chapter 2 Summary. end of a string, in which case the string can span multiple lines.

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

Transcription:

List of Topics for Exam 1 If statements o How is an if statement constructed? o Does every if need an else? Looping o While loop! What does a while loop look like?! How do you ensure you will not have an infinite loop?! In which cases would you want to use a while loop over a for loop? o For loop! What does a for loop look like?! In what cases would you use a for loop over a while loop?! What is this? for( ; ; ){ Types o Type Safety o Valid operations on types o What types can be assigned to what types?! Can you set an int equal to a double? o Initial values! string s; // Value of s?! int x; // Value of x? Functions o Basic composition of a function o How to call a function o Return values! What are they?! How do you capture the result? Errors o What are the types of errors possible in your program? o What are ways to check for errors? o What is the difference between pre- conditions and post- conditions? o What is debugging? o What are methods to make debugging easier?! Comments Naming o What are valid names? o What are not valid names? o Are there words you cannot use for naming? Grammars o What is the purpose of a grammar? o How does the calculator grammar ensure order of operations? Input/Output Streams o What does cout do?

o How do you use cout? o What does cin do? o What does getline() do? o How do you use getline()? o What are the four states of input streams?! What are the differences between them?

Exam 1 mock- up questions 1. What is the return type of this C++ function? double add( double n1, double n2){ return n1+n2; a) Nothing b) This isn t a function c) A double d) Some sort of number, but who knows what kind? e) An int 2. What is the name of this C++ function? double add( double n1, double n2){ return n1+n2; a) add b) double c) return d) function e) Oh gosh. I m taking a test?! 3. What is the output in the cout statement? double add( double n1, double n2){ return n1+n2; int main(){ double x = 0.0; add(5.0, 2.0); cout << x << endl; a) 7.0 b) 5..0 c) 0.0 d) 2.0 e) x

4. What is the output in the cout statement? double add( double n1, double n2){ return n1+n2; int main(){ double x = 0.0; x = add(5.0, 2.0); cout << x << endl; a) 5.0 b) 7.0 c) 2.0 d) 0.0 e) x 5. Which of these is a valid variable name? a) int 1; b) string name; c) double 2CoolForSchool; d) string if; e) string first name; 6. std_lib_facilities_4.h a) is a header file b) contains code for sqare root (sqrt function) c) should be included with a #include d) a && b e) a && c 7. Why is there a return 0 statement in main? a) main returns nothing b) main returns an int c) it symbolizes failure d) it symbolizes success e) b && d f) b && c 8. What does && mean? a) No idea b) OR c) AND d) XOR

9. What does mean? a) The opposite of && b) OR c) AND d) XOR e) Never seen it before in my life 10. In an if statement, what goes inside the parentheses? a) if statements don t have parentheses b) A condition that will evaluate to true or false c) A Boolean value d) Wait a bool is something that is true or false, so it must be b AND c 11. In a while loop, what goes inside the parentheses? a) While loops don t have parentheses b) A condition that will evaluate to true or false c) A Boolean value d) Wait a bool is something that is true or false, so it must be b AND c 12. In C++, what goes inside curly brackets, {? a) code to execute b) C++ doesn t use curly brackets c) Conditions that define whether code will execute or not d) None of the above 13. What is the output of the following code? int i = 0; while ( i < 10 ) cout << i << ; a) This loop will never terminate b) 0 1 2 3 4 5 6 7 8 9 c) 0123456789 d) 0 1 2 3 4 5 6 7 8 9 10 e) 012345678910

14. What is the output of the following code? int i = 0; for(i = 0; i < 10; i = i + 2) cout << i << ; cout << i*2 << ; a) 0 1 2 3 4 5 6 7 8 9 b) 0 2 4 6 8 10 c) 0 0 2 4 4 8 6 12 8 16 d) 0 2 4 6 8 e) 0 2 4 6 8 16 f) 0 2 4 6 8 20 g) Nick, why are you being so mean?! 15. In c++, what does cout do? a) Reads something from the keyboard into a variable b) Prints something to the screen c) Invokes the compiler d) Causes a warning e) Crashes the computer 16. In c++, what does cin do? a) Reads something from the keyboard into a variable b) Prints something to the screen c) Invokes the compiler d) Causes a warning e) Crashes the computer 17. Pair things up correctly a) cin, << b) cout, >> c) cout, << d) cin, output e) cin, <> 18. What is \t? a) It means divide by t b) A multi- character string meaning tab c) A single- character meaning tab d) The italicize command e) None of the above

19. What does the compiler output? a) A source code file b) An object code file c) An executable file d) A header file e) What is a compiler?! 20. What does cin >> x do? a) Read a string and put it into x b) Read a double and put it into x c) Read only whitespace and put it into x d) Ignore leading whitespace before x e) Read as much data that is consistent with the type of x f) D and E sound good g) A and D sound good h) B and D sound good i) Why are there so many options?! 21. The first element of a vector v is indicated by? a) v[0] b) v[1] c) v@0 d) v@1 e) v(0) 22. What does a vector do? a) It stores values sequentially b) It stores duplicate values c) It sores different value types d) It is used to count up in a while loop e) It has something to do with math 23. What does the statement vector<int> v(10) mean? a) A vector, named v, contains 10 integers b) A vector, named int, contains 10 v s c) A vector, named v, contains the int 10 d) A vector, named v, can only store values up to 10 e) What is this?!

24. A a C++ token, as seen in class a) Is something invented by Dr. Daugherity to mess with my head b) Is a user defined type c) Is something to use in an arcade d) Is composed of three fields,: a kind, a value, and a name e) Is both B and D 25. A grammar contains a) Rules to generate valid expressions b) Rules to specify the order of operations c) Green underlining in a word processor d) A and B e) None of the above