CSI33 Data Structures

Similar documents
Understanding main() function Input/Output Streams

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

Chapter 1 Introduction to Computers and C++ Programming

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

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

C++ Basics. Lecture 2 COP 3014 Spring January 8, 2018

Objectives. In this chapter, you will:

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

Computer Programming : C++

Chapter 2. Outline. Simple C++ Programs

Scientific Computing

CSI33 Data Structures

The C++ Language. Arizona State University 1

3. Except for strings, double quotes, identifiers, and keywords, C++ ignores all white space.

6.096 Introduction to C++ January (IAP) 2009

UEE1302 (1102) F10: Introduction to Computers and Programming

Engineering Problem Solving with C++, Etter/Ingber

! A literal represents a constant value used in a. ! Numbers: 0, 34, , -1.8e12, etc. ! Characters: 'A', 'z', '!', '5', etc.

LECTURE 02 INTRODUCTION TO C++

BIL 104E Introduction to Scientific and Engineering Computing. Lecture 1

Chapter 2: Introduction to C++

Chapter 2: Special Characters. Parts of a C++ Program. Introduction to C++ Displays output on the computer screen

CSCE 110 PROGRAMMING FUNDAMENTALS

Chapter 1 INTRODUCTION

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

Tutorial-2a: First steps with C++ programming

Presented By : Gaurav Juneja

Introduction to Programming

2.1. Chapter 2: Parts of a C++ Program. Parts of a C++ Program. Introduction to C++ Parts of a C++ Program

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

Strings and Streams. Professor Hugh C. Lauer CS-2303, System Programming Concepts

C and C++ I. Spring 2014 Carola Wenk

EL2310 Scientific Programming

CSc Introduction to Computing

Lecture 1: Preliminaries

C++ Support Classes (Data and Variables)

Features of C. Portable Procedural / Modular Structured Language Statically typed Middle level language

Lab 1: First Steps in C++ - Eclipse

Chapter 2 Basic Elements of C++

MA400: Financial Mathematics

Chapter 1 An Introduction to C++, Unix, SSH and Komodo Edit

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

Full file at

c++ keywords: ( all lowercase ) Note: cin and cout are NOT keywords.

Chapter 1 & 2 Introduction to C Language

Key Differences Between Python and Java

4. Structure of a C++ program

UNIT- 3 Introduction to C++

IT 374 C# and Applications/ IT695 C# Data Structures

CS2141 Software Development using C/C++ Compiling a C++ Program

2 nd Week Lecture Notes

EL2310 Scientific Programming

A Fast Review of C Essentials Part I

A First Program - Greeting.cpp

COMP322 - Introduction to C++ Lecture 01 - Introduction

CS242 COMPUTER PROGRAMMING

INTRODUCTION 1 AND REVIEW

Lecture 2 Tao Wang 1

BTE2313. Chapter 2: Introduction to C++ Programming

Object-Oriented Programming

AN OVERVIEW OF C. CSE 130: Introduction to Programming in C Stony Brook University

Outline. Review of Last Week II. Review of Last Week. Computer Memory. Review Variables and Memory. February 7, Data Types

Creating a C++ Program

Introduction to C++ Programming. Adhi Harmoko S, M.Komp

Introduction to C++ (Extensions to C)

C++ for Python Programmers

Java Bytecode (binary file)

Getting started 7. Performing operations 25

Linux Tutorial #1. Introduction. Login to a remote Linux machine. Using vim to create and edit C++ programs

Basic program The following is a basic program in C++; Basic C++ Source Code Compiler Object Code Linker (with libraries) Executable

Chapter 2: Overview of C++

Superior University. Department of Electrical Engineering CS-115. Computing Fundamentals. Experiment No.1

EP241 Computer Programming

CHAPTER-6 GETTING STARTED WITH C++

Dr. Md. Humayun Kabir CSE Department, BUET

Introduction to Programming using C++

Streams. Ali Malik

Working with JavaScript

C++ Programming Basics

Your First C++ Program. September 1, 2010

Makefiles Makefiles should begin with a comment section of the following form and with the following information filled in:

Chapter 2. Lexical Elements & Operators

BITG 1233: Introduction to C++

Programming with C++ as a Second Language

Chapter 1 An Introduction to C++, Unix, SSH and Komodo Edit

PART I. Part II Answer to all the questions 1. What is meant by a token? Name the token available in C++.

Introduction to C++ IT 1033: Fundamentals of Programming

CS101: Fundamentals of Computer Programming. Dr. Tejada www-bcf.usc.edu/~stejada Week 1 Basic Elements of C++

Preview from Notesale.co.uk Page 6 of 52

Computers Programming Course 5. Iulian Năstac

! A program is a set of instructions that the. ! It must be translated. ! Variable: portion of memory that stores a value. char

CSc 10200! Introduction to Computing. Lecture 2-3 Edgardo Molina Fall 2013 City College of New York

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

Getting started with C++ (Part 2)

CHAPTER 3 BASIC INSTRUCTION OF C++

Introduction to C programming. By Avani M. Sakhapara Asst Professor, IT Dept, KJSCE

Programming. Computer. Program. Programming Language. Execute sequence of simple (primitive) instructions What instructions should be provided?

Problem Solving With C++ Ninth Edition

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

Transcription:

Outline Department of Mathematics and Computer Science Bronx Community College October 22, 2018

Outline Outline 1 Chapter 8: A C++ Introduction For Python Programmers ords Data Types And Variable Declarations put

Outline 1 Chapter 8: A C++ Introduction For Python Programmers ords Data Types And Variable Declarations put

History Early Languages - Ancestors of C++ 1967 - BCPL (Martin Richards, Cambridge) 1969 - B (Thomson and Ritchie, AT&T) 1969 - UNIX Operating System (Kernigan, Ritchie and Thomson, AT&T) 1970 - C Language (Kernigan and Ritchie, AT&T) 1980 - C with Classes (Bjarne Stroustrup, AT&T) 1985 - C++ (Borland, Microsoft, IBM and AT&T) 1990 - Standard Template Library (STL) 1998 - ANSI standards established for C++

Python Translation Process Interpretation Python Translation Python Source (.py file) Python Interpreter Libraries Python Byte Code (.pyc file) Imported Python Bytecode Python Interpreter Translates and executes one bytecode instruction at a time

C++ Translation Process - Building a Program Compilation C++ Translation (Compilation) C++ Source (.cpp file) C++ Preprocessor Preprocessed C++ file C++ Compiler Object Code File (.obj)

C++ Translation Process - Building a Program Linking C++ Translation (Linking and Running) Object Code File Object Code File (.obj) Static Linked Libraries C++ Linker Executable Machine Code file (.exe)

C++ Translation Process - Building a Program Execution C++ Translation (Execution) Executable Machine Code file (.exe) Dynamic Linked Libraries Running program

Comments Single-Line Or Multiline A single-line comment begins with // A multiline comment begins with /* and ends with */

Whitespace and Blocks of Code Whitespace Whitespace consists of spaces, tabs, and newline characters. C++ uses whitespace as a separator between keywords, identifiers, and operation symbols. There is no other special meaning for whitespace. Indentation is done for readability only it is not used for the body of a function, a loop, or an if/else clause.

Blocks Of Code Function Bodies In C++, instead of indentation, function bodies and if clauses are specified by enclosing them in curly brace symbols { and }. The code inside a pair of braces is called a Code Block.

Identifiers And Keywords Keywords Words which have special meaning for C++ cannot be used as identifiers for variables, function names, or class names.

Identifiers And Keywords Identifiers An identifier can be any sequence of letters (uppercase or lowercase), decimal digits (0-9) or the underscore character, as long as the sequence does not spell a keyword, and as long as the first character of the identifier is not a digit.

Data Types Variables Hold Values (Not References) In Python, every variable name uses a reference ( a four-byte address), which can point to any type of data (int, str, or any object). The type of a variable can be changed by an assignment statement. Python is said to use dynamic typing.

Data Types In C++, Declarations Are Required In C++, every variable uses its actual value, so the compiler needs to know the type of data a variable will take, since different types occupy different amounts of memory. The compiler reserves as many bytes of memory as required for each declared variable, based on the data type specified in the declaration. int = 4 bytes: the declaration int a; allocates 4 bytes for a char = 1 byte: the declaration char c; allocates 1 byte for c double = 8 bytes: the declaration double d; allocates 8 bytes for d bool = 1 byte: the declaration bool b; allocates 1 byte for b

Include Statements Include Statements in C++ Are Like Import Statements in Python In C++, an include statement is used to copy the contents from another file into the file being translated. This is useful, for example, when the same variable is used in different C++ program files since its declaration can be written once and then included whenever that variable is used.

Namespaces Namespaces Are Like Modules in Python In Python, if a variable in one module has the same name as one in another module, the two variables are kept separate by Python, and can have different values. In C++, declaring and naming a namespace (surrounded with braces) will cause every variable declared in the namespace to exist separately from any variable with the same name declared outside the namespace.

Input/Output cin and cout cin is an object in the istream class. Using the >> operator, it allows user input, from the keyboard, to become a variable s value: cin >> a; cout is an object in the ostream class. Using the << operator, it allows a variable s values to become output on the display console: cout << a;

Input/Output Hello, world // hello.cpp #include <iostream> using namespace std; int main() { cout << "hello world\n"; system("pause"); return 0; }

Build The make Utility A script (short program) which tells the computer to perform the steps of building an executable file: Preprocessing and compiling a.cpp file into an object(.o) file. Linking the object file with other machine code files to produce an executable (.exe) file. Only perform operations if the output file is older than the input file.

Build Eclipse Console View **** Build of configuration Debug for project HelloWorld **** **** Internal Builder is used for build **** g++ -O0 -g3 -Wall -c -fmessage-length=0 -ohello.o..\hello.cpp g++ -ohelloworld.exe hello.o Build complete for project HelloWorld Time consumed: 2266 ms.