Data Structures and Programming with C++

Similar documents
EP241 Computer Programming

Introduction to C++ Introduction to C++ 1

Data Structures and Programming with C++

Dr. Md. Humayun Kabir CSE Department, BUET

Data Structures and Programming with C++

Streams. Ali Malik

Outline. Introduction. Arrays declarations and initialization. Const variables. Character arrays. Static arrays. Examples.

Understanding main() function Input/Output Streams

Cours de C++ Introduction

Partha Sarathi Mandal

C++ As A "Better C" Chih-Wei Tang ( 唐之瑋 ) Department of Communication Engineering National Central University JhongLi, Taiwan.

Computer Programming : C++

Scientific Computing

AN OVERVIEW OF C++ 1

CS 376b Computer Vision

Computer Science II Lecture 1 Introduction and Background

Computer Programming. Dr. Fahad Computer Science Deptt.

Chapter 1 Introduction to Computers and C++ Programming

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

Chapter 15 - C++ As A "Better C"

CS242 COMPUTER PROGRAMMING

6.096 Introduction to C++ January (IAP) 2009

CS 11 C++ track: lecture 1

CS 241 Computer Programming. Introduction. Teacher Assistant. Hadeel Al-Ateeq

Introduction to C++ IT 1033: Fundamentals of Programming

1a Computers, Problem Solving!

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

Chapter 1 Introduction to Computers and Programming

Programming with C++ as a Second Language

In this chapter you will learn:

CHAPTER 4 FUNCTIONS. Dr. Shady Yehia Elmashad

COMP322 - Introduction to C++ Lecture 01 - Introduction

Kingdom of Saudi Arabia Princes Nora bint Abdul Rahman University College of Computer Since and Information System CS242 ARRAYS

Chapter 1: An Overview of Computers and Programming Languages. Objectives. Objectives (cont d.) Introduction

Introduction to C++ Systems Programming

Computer Programming

Pointers II. Class 31

A brief introduction to C++

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

CHAPTER 4 FUNCTIONS. Dr. Shady Yehia Elmashad

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

Introduction. Arizona State University 1

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

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

Introduction to Programming

(5-1) Object-Oriented Programming (OOP) and C++ Instructor - Andrew S. O Fallon CptS 122 (February 4, 2019) Washington State University

CSI33 Data Structures

Ch 1. Algorithms and Basic C++ Programming

CS11 Intro C++ Spring 2018 Lecture 1

Multimedia-Programmierung Übung 3

C++ Basics. Data Processing Course, I. Hrivnacova, IPN Orsay

SRM ARTS AND SCIENCE COLLEGE SRM NAGAR, KATTANKULATHUR

CHAPTER 2.1 CONTROL STRUCTURES (SELECTION) Dr. Shady Yehia Elmashad

Fast Introduction to Object Oriented Programming and C++

Final Examination Semester 2 / Year 2005

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

LAB 4 Extending Signed and Unsigned Numbers

Introduction to C++ Professor Hugh C. Lauer CS-2303, System Programming Concepts

CS

CS 31 Discussion 1A, Week 1. Zengwen Yuan (zyuan [at] cs.ucla.edu) Humanities A65, Friday 10:00 11:50

Introduction to C ++

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

Object Oriented Design

Working with Batches of Data

CSE 333 Lecture 9 - intro to C++

Type Aliases. Examples: using newtype = existingtype; // C++11 typedef existingtype newtype; // equivalent, still works

Computational Physics Operating systems

Chapter 1 INTRODUCTION

Functions. CS111 Lab Queens College, CUNY Instructor: Kent Chin

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

Introduction to C++ SSE2034: System Software Experiment 3, Fall 2018, Jinkyu Jeong

Lab 2.1: Fixing a C++ program

OBJECT ORIENTED PROGRAMMING

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

The Parts of a C++ Program

assembler Machine Code Object Files linker Executable File

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

CSI33 Data Structures

Exercise 1.1 Hello world

CHAPTER 4 FUNCTIONS. 4.1 Introduction

Welcome to MCS 360. content expectations. using g++ input and output streams the namespace std. Euclid s algorithm the while and do-while statements

Fundamentals of Structured Programming

Variables and numeric types

Introduction to C++ Dr M.S. Colclough, research fellows, pgtas

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.

IS 0020 Program Design and Software Tools

CS11 Introduction to C++ Fall Lecture 1

A SHORT COURSE ON C++

C, C++, Fortran: Basics

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

CHAPTER 3 ARRAYS. Dr. Shady Yehia Elmashad

1 #include <iostream > 3 using std::cout; 4 using std::cin; 5 using std::endl; 7 int main(){ 8 int x=21; 9 int y=22; 10 int z=5; 12 cout << (x/y%z+4);

Unit 1 : Principles of object oriented programming

UEE1302 (1102) F10: Introduction to Computers and Programming

Chapter 1: Why Program? Computers and Programming. Why Program?

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

MA400: Financial Mathematics

STUDY NOTES UNIT 1 - INTRODUCTION TO OBJECT ORIENTED PROGRAMMING

Chapter 2: Overview of C++

The births of the generations are as follow. First generation, 1945 machine language Second generation, mid 1950s assembly language.

Transcription:

Data Structures and Programming with C++ By Dr. Atul Dwivedi ETC, BIT, Durg UNIT-I B. E., V Semester

Outline Objectives of the Course Syllabus Reference Books Introduction to programming languages Basic C++ Programs Quiz 2

Objectives of the course To gain a better understanding of object-oriented design and program implementation by using object oriented features of C++. Identify the major elements in an object-oriented programming language. Understand some advanced features of C++ including templates, exceptions, and multiple inheritances. 3

Syllabus 4

Reference Books 5

Introduction to programming languages Program Machine language Assembly language High level languages High level languages allow the programmer to write programs without having to be as concerned about what kind of computer the program is being run on. Programs written in high level languages must be translated into a form that the CPU can understand before they can be executed. High Level Language Compiler Interpreter CPU 6

Compiler and interpreter A compiler is a program that reads code and produces a standalone executable program that the CPU can understand directly. Once your code has been turned into an executable, you do not need the compiler to run the program. An interpreter is a program that directly executes your code without compiling it into machine code first. Interpreters tend to be more flexible, but are less efficient when running programs because the interpreting process needs to be done every time the program is run. This means the interpreter is needed every time the program is run. 7

Flow of execution of a C++ Program 8

Background of C++ S.N. Year Event 1. 1979 C++ was developed by Bjarne Stroustrup at Bell Labs as an extension to C 2. 1998 Ratified by ISO 3. 2003 Two updates in C++ for additional functionality 4. 2011, 2014 The two updates were ratified respectively 9

10

Compiling your first program #include <iostream.h> { } int main() std::cout << "Hello world!" ; return 0; // To use gcc compiler open run command window // to compile the program in gcc type g++ programname.cpp //this will create one executable file "a". just type a // in the command line to execute it. //if you want to customize the executable file name you //can write the commnd g++ myfp.cpp -o myfp.o // see myp02 to myp05 to learn some basics of programming 11

Objects C++ programs create, access, manipulate, and destroy objects. An object is a piece of memory that can be used to store values. You can think of an object as a mailbox, or a cubbyhole, where we can store and retrieve information. All computers have memory, called RAM (random access memory), that is available for programs to use. When an object is defined, a piece of that memory is set aside for the object. Most of the objects that we use in C++ come in the form of variables. A variable in C++ is simply an object that has a name. 12

Initialization vs. assignment C++ supports two related concepts that new programmers often get mixed up: assignment and initialization. After a variable is defined, a value may be assigned to it via the assignment operator (the = sign): C++ will let you both define a variable AND give it an initial value in the same step. This is called initialization. 13

cout, cin, and endl std::cout: in the iostream library can be used to output text to the console. Assignment: Print your name, roll no, section, branch and college name using C++. std::cin is the opposite of std::cout -- whereas std::cout prints data to the console using the output operator (<<), std::cin reads input from the user at the console using the input operator (>>). 14

Quiz What is the difference between assembly level and high level programming language? What is the difference between a statement and expression? How will you differentiate a function from a library Which symbol is used at the end of C++ statements What is syntax error? 15

Lab Assignments 1. Write a program that prints your name, roll no, section, branch and college name in different consecutive lines using C++ programming. 2. Write a program to separate all digits of a four digit number and display sum of first and third digit. 3. Write a C++ program to calculate sum of two numbers provided by the user. 4. Calculate total income of a person using five different assets of income. 5. Evaluate the value of y in following expression using C++, if x=2, a=4,b=3 y x 2 b a a 2 x 2 16

Dr. Atul Kumar Dwivedi, BIT Durg, (India) email : atuldwivedi@live.in 8/5/2017 17