Cs 141 Exam 1 Review1 Game Show!. Cs 141 Exam 1 Review2  What type/types hold the following:  'a'  '\n'  '4'

Slides:



Advertisements
Similar presentations
Starting Out with C++, 3 rd Edition 1 Chapter 1. Introduction to Computers and Programming.
Advertisements

CIS 101: Computer Programming and Problem Solving Lecture 8 Usman Roshan Department of Computer Science NJIT.
1 9/29/06CS150 Introduction to Computer Science 1 Loops Section Page 255.
1 9/26/08CS150 Introduction to Computer Science 1 Logical Operators and if/else statement.
1 10/20/08CS150 Introduction to Computer Science 1 do/while and Nested Loops Section 5.5 & 5.11.
1 10/11/06CS150 Introduction to Computer Science 1 do/while and Nested Loops.
CS150 Introduction to Computer Science 1
1 9/20/06CS150 Introduction to Computer Science 1 Review: Exam 1.
1 10/29/07CS150 Introduction to Computer Science 1 Reading from and Writing to Files Section 3.12 & 13.1 & 13.5.
CS31: Introduction to Computer Science I Discussion 1A 4/2/2010 Sungwon Yang
The If/Else Statement, Boolean Flags, and Menus Page 180
1 10/25/06CS150 Introduction to Computer Science 1 Reading from and Writing to Files.
What is the out put #include using namespace std; void main() { int i; for(i=1;i
1 9/28/07CS150 Introduction to Computer Science 1 Logical Operators and if/else statement.
Administrative MUST GO TO CORRECT LAB SECTION! Homework due 11:59pm on Tuesday. 25 points off if late (up to 24 hours) Cannot submit after 11:59pm on Wednesday.
Computer Science 1620 Lifetime & Scope. Variable Lifetime a variable's lifetime is finite Variable creation: memory is allocated to the variable occurs.
C++ Functions. 2 Agenda What is a function? What is a function? Types of C++ functions: Types of C++ functions: Standard functions Standard functions.
Copyright 2003 Scott/Jones Publishing Brief Version of Starting Out with C++, 4th Edition Chapter 1 Introduction to Computers and Programming.
PRINCIPLES OF PROGRAMMING Revision. A Computer  A useful tool for solving a great variety of problems.  To make a computer do anything (i.e. solve.
VARIABLES, TYPES, INPUT/OUTPUT, ASSIGNMENT OPERATION Shieu-Hong Lin MATH/CS Department Chapel.
Agenda Review Compiling Review Data Types Integer Division Composition C++ Mathematical Functions User Input Reading: , 8.11 Homework #3.
Introduction to C++ - How C++ Evolved Most popular languages currently: COBOL, Fortran, C, C++, Java (script) C was developed in 1970s at AT&T (Richie)
Modular Programming Chapter Value and Reference Parameters t Function declaration: void computesumave(float num1, float num2, float& sum, float&
High-Level Programming Languages: C++
Introduction to C++ Programming Introduction to C++ l C is a programming language developed in the 1970's alongside the UNIX operating system. l C provides.
Chapter 5: Control Structures II (Repetition)
EGR 2261 Unit 5 Control Structures II: Repetition  Read Malik, Chapter 5.  Homework #5 and Lab #5 due next week.  Quiz next week.
Agenda Exam #1 Review Modulus Conditionals Boolean Algebra Reading: Chapter Homework #5.
CIS-165 C++ Programming I CIS-165 C++ Programming I Bergen Community College Prof. Faisal Aljamal.
Chapter 4 Loops Write code that prints out the numbers Very often, we want to repeat a (group of) statement(s). In C++, we have 3 major ways of.
Lecture 4 Looping. Building on the foundation Now that we know a little about  cout  cin  math operators  boolean operators  making decisions using.
6/3/2016 CSI Chapter 02 1 Introduction of Flow of Control There are times when you need to vary the way your program executes based on given input.
CPS120: Introduction to Computer Science Lecture 14 Functions.
Making Decisions (True or False) Relational Operators >greater than =greater than or equal to
CS Class 05 Topics  Selection: switch statement Announcements  Read pages 74-83, ,
Chapter 7 Selection Dept of Computer Engineering Khon Kaen University.
1 EMT 101 – Engineering Programming Dr. Farzad Ismail School of Aerospace Engineering Universiti Sains Malaysia Nibong Tebal Pulau Pinang Week 2.
CS161 Topic #16 1 Today in CS161 Lecture #16 Prepare for the Final Reviewing all Topics this term Variables If Statements Loops (do while, while, for)
C++ Classes and Data Structures Jeffrey S. Childs
Lecture 9: Making Decisions Final Section Professor: Dr. Miguel Alonso Jr. Fall 2008 CGS2423/COP1220.
#include using namespace std; // Declare a function. void check(int, double, double); int main() { check(1, 2.3, 4.56); check(7, 8.9, 10.11); } void check(int.
CHAPTER 10 ARRAYS AND FUNCTIONS Prepared by: Lec. Ghader Kurdi.
Repetition Statements (Loops) The do while Loop The last iteration structure in C++ is the do while loop. A do while loop repeats a statement or.
CS1201: PROGRAMMING LANGUAGE 2 FUNCTIONS. OVERVIEW What is a Function? Function Prototype Vs Decleration Highlight Some Errors in Function Code Parameters.
Cs 141 Exam 2 Review1 Game Show!. Cs 141 Exam 2 Review2 Whats wrong with this function bool foo (int, double){ return true; }
April 11, 2005 More about Functions. 1.Is the following a function call or a function header? calcTotal(); 2.Is the following a function call or a function.
Fundamental Programming Fundamental Programming More Expressions and Data Types.
1 2/2/05CS250 Introduction to Computer Science II Pointers.
Variables  A piece of memory set aside to store data  When declared, the memory is given a name  by using the name, we can access the data that sits.
CS Class 04 Topics  Selection statement – IF  Expressions  More practice writing simple C++ programs Announcements  Read pages for next.
CS 1428 Final Exam Review. Exam Format 200 Total Points – 60 Points Writing Programs – 45 Points Tracing Algorithms and determining results – 20 Points.
CSC 107 – Programming For Science. Today’s Goal  Write functions that take & return values  How parameters declared and how we call functions  What.
Function Parameters and Overloading Version 1.0. Topics Call-by-value Call-by-reference Call-by-address Constant parameters Function overloading Default.
Basic concepts of C++ Presented by Prof. Satyajit De
MT262A Review.
Introduction to C++ Introduced by Bjarne Stroustrup of AT&T’s Bell Laboratories in mid-1980’s Based on C C++ extended C to support object-oriented programming.
Chapter 1. Introduction to Computers and Programming
Variables A piece of memory set aside to store data
New Structure Recall “average.cpp” program
Quiz Next Monday.
CS 1430: Programming in C++ No time to cover HiC.
Counting Loops.
Introduction to C++ Introduced by Bjarne Stroustrup of AT&T’s Bell Laboratories in mid-1980’s Based on C C++ extended C to support object-oriented programming.
If Statements.
CS150 Introduction to Computer Science 1
2. Second Step for Learning C++ Programming • Data Type • Char • Float
Programming Introduction to C++.
do/while Selection Structure
Fundamental Programming
CS 101 First Exam Review.
Presentation transcript:

Cs 141 Exam 1 Review1 Game Show!

Cs 141 Exam 1 Review2  What type/types hold the following:  'a'  '\n'  '4'

Cs 141 Exam 1 Review3  What type/types hold the following:  0,1,-1,2,-2,...

Cs 141 Exam 1 Review4  What is the main difference between the values that can be stored in an int variable and the set of all integers that you learned about in math?

Cs 141 Exam 1 Review5  What type/types hold the following: 0,1,2,3,4,...

Cs 141 Exam 1 Review6  What type/types could be legitimately substituted for TYPE TYPE foo = 4;

Cs 141 Exam 1 Review7  What is the main difference between a float and a double?

Cs 141 Exam 1 Review8 int bar = 23/4; What is bar?

Cs 141 Exam 1 Review9 int foo = 23%4; What is foo?

Cs 141 Exam 1 Review10 float bop = 23/4; What is bop?

Cs 141 Exam 1 Review11  int baz;  What is the value of baz?

Cs 141 Exam 1 Review12  What are three ways to initialize the value of a variable?

Cs 141 Exam 1 Review13  What would happen if you did this:  const int foo = 5;  foo = 10;

Cs 141 Exam 1 Review14  Is this a valid comment?  /* Written by Jeanna

Cs 141 Exam 1 Review15  Is this a valid comment?  \\ Written by Jeanna

Cs 141 Exam 1 Review16  What are two ways to write a valid comment?

Cs 141 Exam 1 Review17  Declare a variable to hold someone's last name.

Cs 141 Exam 1 Review18  Declare a variable to hold someone's age in years.

Cs 141 Exam 1 Review19  Declare a variable to hold someone's hourly wage.

Cs 141 Exam 1 Review20  Declare a variable to hold someone's middle initial.

Cs 141 Exam 1 Review21  If you wanted to declare a variable to keep track of the number of times someone blinks in a year, what would be a good choice for the type and why?

Cs 141 Exam 1 Review22 What does != mean?

Cs 141 Exam 1 Review23  What is the difference between = and ==?

Cs 141 Exam 1 Review24  What does && mean?

Cs 141 Exam 1 Review25  What does || mean?

Cs 141 Exam 1 Review26  What is the difference between: cin >> foo; cout << foo;

Cs 141 Exam 1 Review27  Which of these lines is not like the others? foo++; ++foo; foo+=1; foo = foo +1; foo+1;

Cs 141 Exam 1 Review28  What is wrong with this? if ((answer == ‘y’) | (answer == ‘Y’)){ cout << “User entered yes\n”; }

Cs 141 Exam 1 Review29  What is wrong with this? if ((answer == ‘y’) && (answer == ‘Y’)){ cout << “User entered yes\n”; }

Cs 141 Exam 1 Review30 What will happen if you do this? num =3; if (num =2){ cout << “Number is 2\n”; } else { cout << “Number is not 2\n”; }

Cs 141 Exam 1 Review31 What will happen if you do this num =3; if (num !=2){ cout << “Number is not 2\n”; } else if (num < 4) { cout << “Number is less than 4\n”; } else if (num >0){ cout << “Number is greater than 0\n”; }

Cs 141 Exam 1 Review32  What is the value of BAZ below? enum SillyNames {FOO=1, BAR, BAZ};

Cs 141 Exam 1 Review33  Declare an enum of the days of the week.

Cs 141 Exam 1 Review34  What is the advantage of declaring an enum?

Cs 141 Exam 1 Review35  Are these two boolean expressions the same? (x >=10) ((x ==10) && (x > 10))

Cs 141 Exam 1 Review36  There are 3 different types of clauses in an if statement: if, else if and else  How many of each can you have?

Cs 141 Exam 1 Review37  Identify the following in this loop: InitializationActions, LoopCondition, UpdateActions, BodyStatements, CompletionActions total =0; i=0; while (i< 10){ total = total +i; i++; } cout << total;

Cs 141 Exam 1 Review38  Identify the following in this loop: InitializationActions, LoopCondition, UpdateActions, BodyStatements, CompletionActions for(i=0; i< 10; i++){ total = total +i; } cout << total;

Cs 141 Exam 1 Review39  Identify the following in this loop: InitializationActions, LoopCondition, UpdateActions, BodyStatements, CompletionActions howMany=0; while(input_stream >> num){ howMany++; total = total + num; } average = total/howMany;

Cs 141 Exam 1 Review40  If homMany and total are ints, what problem will be have computing average? What could we do to fix the problem? What type should average be? howMany=0; while(input_stream >> num){ howMany++; total = total + num; } average = total/howMany;

Cs 141 Exam 1 Review41 int numbers[3]; How many ints are declared? How would you refer to the first one? The last one? Write a for loop to add them all up

Cs 141 Exam 1 Review42 int numbers[3][2]; How many ints are declared? How would you refer to first one? How would you refer to the last one? Write a for loop to add them all up.

Cs 141 Exam 1 Review43  If you want to read from or write to a file what must you add to our basic template?

Cs 141 Exam 1 Review44 #include

Cs 141 Exam 1 Review45  Declare a variable to hold a file you want to read from

Cs 141 Exam 1 Review46 ifstream input_file;

Cs 141 Exam 1 Review47  Declare a variable to hold a file you want to write to.

Cs 141 Exam 1 Review48 ofstream output_file;

Cs 141 Exam 1 Review49 How would you open the file “foo.txt”?

Cs 141 Exam 1 Review50 fileVariable.open(“foo.txt”);

Cs 141 Exam 1 Review51  If you try to open a file, what type of error should you check for and how do you do that?

Cs 141 Exam 1 Review52 Check if weren't able to open the file fileVariable.open(“foo.txt”); if (fileVariable.fail()){ cout << “Couldn't open the file\n”; }

Cs 141 Exam 1 Review53  How would you open the file foo.txt?

Cs 141 Exam 1 Review54  What does it mean to have a if statement nested inside a loop?

Cs 141 Exam 1 Review55  What does it mean to have nested for loops?  What are nested for loops especially good for?

Cs 141 Exam 1 Review56  True or false: There are some problems for which you must use a do-while loop. A while loop just won't work.

Cs 141 Exam 1 Review57  When is it generally better to use a do- while loop instead of a while loop?

Cs 141 Exam 1 Review58  When is it generally better to use a for loop instead of a while loop or do-while loop?

Cs 141 Exam 1 Review59  When you get a bunch of compiler errors which one should you fix first and why?

Cs 141 Exam 1 Review60  If you are trying to fix a specific compiler error, how can you figure out where the problem is?

Cs 141 Exam 1 Review61  What is a fence post error?

Cs 141 Exam 1 Review62  If you were going to test this loop what would be three great values of x to test? Why? cin >> x; for (int i=0; i< x; i++){ cout << i; }

Cs 141 Exam 1 Review63 Will these do the same thing? for (i=0; i< 3;i++ ) cout << i; for (i=0;i< 3 ){ cout << i; i++; }

Cs 141 Exam 1 Review64 Will these do the same thing? for (i=0; i< 3;i++ ) cout << i; i=0; while (i< 3 ) cout << i++;

Cs 141 Exam 1 Review65  What would you expect to happen if you did this int numArray[5]; numArray[5] = 100; cout << numArray[5];

Cs 141 Exam 1 Review66 Whats wrong with this int numArray[9]; for (int i=0; i<=9; i++){ numArray[i] = i; }

Cs 141 Exam 1 Review67 Do these all do the same thing? cout << num << “\n”; cout << num << endl; cout << num; cout << “\n”;

Cs 141 Exam 1 Review68  What child of a famous British poet is often considered the first programmer?

Cs 141 Exam 1 Review69 Ada Byron Lovelace ( )

Cs 141 Exam 1 Review70  Who is the creator of C++?

Cs 141 Exam 1 Review71 Bjarne Stroustrup

Cs 141 Exam 1 Review72  Who is the creator of the C programming language and a co-author of the UNIX operating system?

Cs 141 Exam 1 Review73 Dennis Ritchie

Cs 141 Exam 1 Review74  Explain the joke in the name C++

Cs 141 Exam 1 Review75  Who coined the term “debugging” and wrote the first compiler for a computer programming language?

Cs 141 Exam 1 Review76 Rear Admiral Grace Hopper

Cs 141 Exam 1 Review77 Picture of the moth that was the first computer “bug”

Cs 141 Exam 1 Review78 Who is this?

Cs 141 Exam 1 Review79  Linus Torvalds author and developer of Linux

Cs 141 Exam 1 Review80 Who is this?

Cs 141 Exam 1 Review81  Steve Jobs, co-founder and CEO of Apple Corporation

Cs 141 Exam 1 Review82 Who is this?

Cs 141 Exam 1 Review83  Steve Wozniak, co-founder of Apple Corporation

Cs 141 Exam 1 Review84  What does IBM stand for?

Cs 141 Exam 1 Review85  International Business Machines

Cs 141 Exam 1 Review86  Who is considered the founder of IBM?

Cs 141 Exam 1 Review87 Thomas J. Watson

Cs 141 Exam 1 Review88 Whats wrong with this function bool foo (int, double){ return true; }

Cs 141 Exam 1 Review89 Whats wrong with this function void doubleIt(int num){ num = 2* num; }

Cs 141 Exam 1 Review90 Whats wrong with this function int double bar(int num){ return num; }

Cs 141 Exam 1 Review91 Whats wrong with this function void doubleIt(int num){ return 2* num; }

Cs 141 Exam 1 Review92 void baz (int num1, int &num); Which is the call by value parameter and which is the call by reference parameter?

Cs 141 Exam 1 Review93  What does call by value mean?

Cs 141 Exam 1 Review94  What does call by reference mean?

Cs 141 Exam 1 Review95 void bar(int numArray[]){ } Is numArray call by value or call by reference?

Cs 141 Exam 1 Review96 What do you have to do to make an array parameter call by value?

Cs 141 Exam 1 Review97  What does procedural abstraction or information hiding or black box design mean?

Cs 141 Exam 1 Review98  What is the purpose of assertions?

Cs 141 Exam 1 Review99  How can you turn off assertions before you release code to users?

Cs 141 Exam 1 Review100  Why would you turn off assertions before you release code to users?

Cs 141 Exam 1 Review101  Give me an example of function overloading?

Cs 141 Exam 1 Review102  What is meant by a global variable?

Cs 141 Exam 1 Review103  Where are global variables declared?

Cs 141 Exam 1 Review104  What is the type of variable used for output files?

Cs 141 Exam 1 Review105  What is the type of variable used for input files?

Cs 141 Exam 1 Review106  How do you test if a file open succeeds?

Cs 141 Exam 1 Review107  How do you test if a file read or write succeeds?

Cs 141 Exam 1 Review108  How do you test if you read all the contents of a file?

Cs 141 Exam 1 Review109  What do you add to the file open call if you want to append to a file?

Cs 141 Exam 1 Review110  If I did this ./a.out inputFile.txt  What would argc be?

Cs 141 Exam 1 Review111  If I did this ./a.out inputFile.txt  What would argv[1] be?

Cs 141 Exam 1 Review112