Review Binary Numbers Bit : 0 or 1 Byte: 8 bites 256 different values 2 8 KB : 1024 bytes 2 10 bytes MB : 1024 * 1024 bytes 2 10 * 2 10 (2 20 ) bytes GB.

Slides:



Advertisements
Similar presentations
C Language.
Advertisements

Array. Convert Numbers in Different Base Systems Generate values to a series of numbers in different base systems: Base is between 2 and 9; Maximum number.
True or false A variable of type char can hold the value 301. ( F )
C++ Basics Prof. Shermane Austin. Learning Programming Language Basics Data Types – simple Expressions Relational and Logical Operators Conditional Statements.
Arrays An array is a sequence of objects all of which have the same type. The objects are called the elements of the array and are numbered consecutively.
Computer programming1 Arrays. Computer programming2 ARRAYS Motivation Introduction to Arrays Static arrays Arrays and Functions Arrays, Classes, and typedef.
Wednesday, 12/11/02, Slide #1 CS 106 Intro to Comp. Sci. 1 Wednesday, 12/11/02  QUESTIONS??  Today: CLOSING CEREMONIES!  HW #5 – Back Monday (12/16)
Arrays Hanly - Chapter 7 Friedman-Koffman - Chapter 9.
Monday, 11/18/02, Slide #1 CS 106 Intro to CS 1 Monday, 11/18/02  QUESTIONS??  Today:  Hand back, discuss HW #4  Discussion of Lab 10  Exam #2 Friday.
Chapter 8 Arrays and Strings
CSCI/CMPE 4341 Topic: Programming in Python Chapter 3: Control Structures (Part 1) – Exercises 1 Xiang Lian The University of Texas – Pan American Edinburg,
Arrays.
CS 117 Spring 2002 Review for Exam 3 arrays strings files classes.
Elements of a C++ program 1. Review Algorithms describe how to solve a problem Structured English (pseudo-code) Programs form that can be translated into.
1 Introduction to Arrays Problem: –Input 5 scores, compute total, average –Input Example –test scores,employees,temperatures.
C++ Arrays. Agenda What is an array? What is an array? Declaring C++ arrays Declaring C++ arrays Initializing one-dimensional arrays Initializing one-dimensional.
 200 Total Points ◦ 74 Points Writing Programs ◦ 60 Points Tracing Algorithms and determining results ◦ 36 Points Short Answer ◦ 30 Points Multiple Choice.
Chapter 8 Arrays and Strings
Program A computer program (also software, or just a program) is a sequence of instructions written in a sequence to perform a specified task with a computer.
CS 2430 Day 1. Agenda Load NetBeans Introduction Syllabus Review some array operations.
C++ Programming: From Problem Analysis to Program Design, Fifth Edition Arrays.
CIS-165 C++ Programming I CIS-165 C++ Programming I Bergen Community College Prof. Faisal Aljamal.
CS Midterm Study Guide Fall General topics Definitions and rules Technical names of things Syntax of C++ constructs Meaning of C++ constructs.
CHAPTER 7 arrays I NTRODUCTION T O C OMPUTER P ROGRAMMING (CSC425)
Organizing Heterogeneous Data Arrays allow a programmer to organize lists of values that are all of the same type (homogeneous). But we are often faced.
Section 5 - Arrays. Problem solving often requires information be viewed as a “list” List may be one-dimensional or multidimensional List is implemented.
C++ Basics. Compilation What does compilation do? g++ hello.cpp g++ -o hello.cpp hello.
1 Cannon_Chapter9 Strings and the string Class. 2 Overview  Standards for Strings  String Declarations and Assignment  I/O with string Variables 
Quiz // // The function exchanges the two parameters. // Param: ( ) // Param:
(7-2) Arrays I H&K Chapter 7 Instructor - Andrew S. O’Fallon CptS 121 (October 9, 2015) Washington State University.
Review for Final Exam. Contents 5 questions (20 points each) + 1 bonus question (20 points) – Basic concepts in Chapters 1-4 – Chapters 5-9 – Bonus: Chapter.
Liang, Introduction to Programming with C++, Second Edition, (c) 2010 Pearson Education, Inc. All rights reserved Chapter 6 Arrays.
Copyright © 2000, Department of Systems and Computer Engineering, Carleton University 1 Introduction An array is a collection of identical boxes.
1 Chapter 12 Arrays. 2 C++ Data Types structured array struct union class address pointer reference simple integral enum char short int long bool floating.
Variables and memory addresses
Data Types Storage Size Domain of all possible values Operations 1.
Arrays.
2: Basics Basics Programming C# © 2003 DevelopMentor, Inc. 12/1/2003.
Higher Computing Science 2016 Prelim Revision. Topics to revise Computational Constructs parameter passing (value and reference, formal and actual) sub-programs/routines,
Class Method Read class Student { private: string id; string firstName, lastName; float gpa; public: // Will the method change any data members? // Yes!
Lecturer: Nguyen Thi Hien Software Engineering Department Home page: hienngong.wordpress.com Chapter 2: Language C++
C++ Programming Lecture 14 Arrays – Part I The Hashemite University Computer Engineering Department (Adapted from the textbook slides)
C++ Basics Programming. COMP104 Lecture 5 / Slide 2 Introduction to C++ l C is a programming language developed in the 1970s with the UNIX operating system.
CS 1430: Programming in C++ 1. Test 2 Friday Functions Arrays For Loops Understand Concepts and Rules Memorize Concepts and Rules Apply Concepts and Rules.
Exception Handling How to handle the runtime errors.
Array and Pointers An Introduction Unit Unit Introduction This unit covers the usage of pointers and arrays in C++
CS Class 04 Topics  Selection statement – IF  Expressions  More practice writing simple C++ programs Announcements  Read pages for next.
CS 1430: Programming in C++.
Array. Array is a group of data of the same type. Array elements have a common name –The array as a whole is referenced through the common name Individual.
Activation Record int main() { float allScores[MAX_ROWS][MAX_COLS]; int rows, cols; GetAllData(allScores, rows, cols);... } 1 void GetAllData(float a[][MAX_COLS],
CS 1428 Final Exam Review. Exam Format 200 Total Points – 60 Points Writing Programs – 45 Points Tracing Algorithms and determining results – 20 Points.
Arrays float Scores[9]; ? index: element // one dimensional array 2.
Data Storage So far variables have been able to store only one value at a time. What do you do if you have many similar values that all need to be stored?
Lecture 6 C++ Programming
CS 1430: Programming in C++.
Advanced Programming Behnam Hatami Fall 2017.
CS 1430: Programming in C++.
CS 1430: Programming in C++.
CS 2308 Exam I Review.
Enumeration Data Type enum Day {SUN, MON, TUE, WED, THU, FRI, SAT};
COMPUTER 2430 Object Oriented Programming and Data Structures I
CS 1430: Programming in C++ No time to cover HiC.
Review for Final Exam.
CS 1428 Final Exam Review.
CS 1430: Programming in C++.
CS 1428 Final Exam Review.
Review for Final Exam.
Fundamental Programming
Fundamental Programming
CS 101 First Exam Review.
Presentation transcript:

Review Binary Numbers Bit : 0 or 1 Byte: 8 bites 256 different values 2 8 KB : 1024 bytes 2 10 bytes MB : 1024 * 1024 bytes 2 10 * 2 10 (2 20 ) bytes GB : 1024 * 1024 * 1024 bytes 2 10 * 2 10 * 2 10 (2 30 ) bytes 1

Data Types char int (short, long) float (double) bool string (C++ string) array (2-D Array) C String (array of char) Enum (typedef) Classes 2

Data Types Storage Values Operations 3

Input cin >> mostVal; cin.get(charVal); inFile >> mostVal; inFile.get(charVal); Output Arithmetic operations float division integer division (remainder) Assignment Comparison Function parameter Function return value 4

Classes Construct or class Student: string id, name; float gpa; class Section: Student students[26]; int numStudents; class UWPClass Section sections[MAX_SIZE]; int numSections; class Department UWPClass allClasses[100]; int numClasses; 5

Classes class Student { private: string id, name; float gpa; public: string getName() { return name; }... } 6

Classes class Student { public: string id, name; float gpa; public: // Not needed string getName() { return name; }... } 7

Char and Int Sometimes char is treated as int (its ASCII code value). char ch = ‘A’; ch ++; cout << ch; cin >> ch; if (ch >= ‘0’ and ch <= ‘9’) cout << “The value is ” << (ch – ‘0’); 8

Important Topics If If – Elseif - Else While and For Loops Tracing function call Pass by value Pass by reference Activation Record Linear search Selection Sort File I/O 9

Review The following declaration is illegal. TRUEFALSE int size = 100; StudentType allStudents[size]; The following declaration is valid. TRUEFALSE int size = 100; float allSscores[size]; 10

Review const int MAX_SIZE = 5000; float scores[MAX_SIZE]; The following operation is invalid. (Assuming values have been entered.) TRUEFALSE for (int i = 0; i <= MAX_SIZE; i ++) cout << setw(9) << scores[i]; // Uninitialized values // Run time Error The above operation is valid. (Assuming values have been entered.) TRUEFALSE 11

Review Find Max Linear (Sequential) Search for (int i = 0; i < size; i ++) // Comparing Not sorted Sorted The last (first) element

Review Find a Number Linear (Sequential) Search for (int i = 0; i < size; i ++) // Comparing Not sorted Sorted Binary Search

Review Functions void SomeFunction(int x, float& y); // Pass by Value or by Reference int xVal = 100, noVal; float yVal = 135.0; SomeFunction(120, noVal); SomeFunction(noVal, yVal); SomeFunction(xVal, yVal + 10); SomeFunction(xVal, xVal); SomeFunction(“120”, yVal); 14

Review Syntax and Style if (index == -1) cout << “Not found”; if (index == -1) cout << “Not found”; // Syntax is OK 15

Review Programming Design Coding Compiling Running (Debugging) Errors Cannot compile Run time error (Uninitialized values) Infinite loop Incorrect results Correct results Good Programs 16

Example int count = 15; while (count > 0); { //do something count --; } How many times will the body be executed? A. 0 B. 1 C. 15 D. Infinity loop E. None of above 17

Example int count; cout >> “Enter count: ”; cin << count; while (count > 0) { //do something count --; } The above code segment A. Cannot compile. B. Will generate a Run time error. C. Will not terminate (Infinity Loop). D. Will generate incorrect result. E. NONE of Above. 18

Example int count = 15; float value, total = 0; while (count > 0) { cin >> value; value += total; count --; } cout << “Total: ” << total; The above code segment A. Cannot compile. B. Will generate a Run time error. C. Will not terminate (Infinity Loop). D. Will generate incorrect result. E. NONE of Above. 19

Final Exam 7:00 – 8:52 PM, Thursday, May 19 Doudna Points 50 points: T/F, Multiple Choices 50 Points: Programming Statements Entire Program Tracing Functions #2 pencil Do it as given in class! Manage your time! 20

Final Exam 21