C++ Introduction. Why Learn C++? Very powerful and respected prog. Lang. Very powerful and respected prog. Lang. Highly respected in Academics Highly.

Slides:



Advertisements
Similar presentations
 C++ programming facilitates a disciplined approach to program design. ◦ If you learn the correct way, you will be spared a lot of work and frustration.
Advertisements

Your First C++ Program Aug 27, /27/08 CS 150 Introduction to Computer Science I C++  Based on the C programming language  One of today’s most.
1 9/1/06CS150 Introduction to Computer Science 1 What Data Do We Have? CS 150 Introduction to Computer Science I.
Chapter 8: Introduction to High-level Language Programming Invitation to Computer Science, C++ Version, Third Edition.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 15 - C++ As A "Better C" Outline 15.1Introduction.
Programming Introduction November 9 Unit 7. What is Programming? Besides being a huge industry? Programming is the process used to write computer programs.
1 8/30/06CS150 Introduction to Computer Science 1 Your First C++ Program.
Introduction to C++CS-2303, C-Term Introduction to C++ CS-2303 System Programming Concepts (Slides include materials from The C Programming Language,
Chapter 8: Introduction to High-level Language Programming Invitation to Computer Science, C++ Version, Third Edition.
 2007 Pearson Education, Inc. All rights reserved C++ as a Better C; Introducing Object Technology.
C++ Programming Language Day 1. What this course covers Day 1 – Structure of C++ program – Basic data types – Standard input, output streams – Selection.
Introduction to C++ Programming
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)
Chapter 3 Getting Started with C++
Instructor: Tina Tian. About me Office: RLC 203A Office Hours: Wednesday 1:30 - 4:30 PM or .
IPC144 Introduction to Programming Using C Week 1 – Lesson 2
Introduction to C++ Systems Programming. Systems Programming: Introduction to C++ 2 Systems Programming: 2 Introduction to C++  Syntax differences between.
Programming for Beginners Martin Nelson Elizabeth FitzGerald Lecture 13: An Introduction to C++
Computer Engineering 1 nd Semester Dr. Rabie A. Ramadan 2.
Chapter 02 (Part III) Introduction to C++ Programming.
Beginning C++ Through Game Programming, Second Edition
COMPUTER PROGRAMMING. A Typical C++ Environment Phases of C++ Programs: 1- Edit 2- Preprocess 3- Compile 4- Link 5- Load 6- Execute Loader Primary Memory.
Chapter 0 Getting Started. Objectives Understand the basic structure of a C++ program including: – Comments – Preprocessor instructions – Main function.
Dynamic Memory. We will follow different order from Course Book We will follow different order from Course Book First we will cover Sect The new.
1 A simple C++ program // ======================================================= // File:helloworld.cpp // Author:Vana Doufexi // Date:1/4/2006 // Description:Displays.
1 COMS 261 Computer Science I Title: C++ Fundamentals Date: September 05, 2005 Lecture Number: 4.
1 8/31/05CS150 Introduction to Computer Science 1 Hello World!
C++ / G4MICE Course Session 1 - Introduction Edit text files in a UNIX environment. Use the g++ compiler to compile a single C++ file. Understand the C++
C++ LANGUAGE TUTORIAL LESSON 1 –WRITING YOUR FIRST PROGRAM.
1 Getting Started with C++ Part 2 Linux. 2 Getting Started on Linux Now we will look at Linux. See how to copy files between Windows and Linux Compile.
Learners Support Publications Introduction to C++
Dayu Zhang 9/10/2014 Lab03. Outline Brief Review of the 4 Steps in Hello.cpp Example Understand endl and \n Understand Comment Programming Exercise -
Brief Version of Starting Out with C++ Chapter 1 Introduction to Computers and Programming.
Std Library of C++ Part 2. vector vector is a collection of objects of a single type vector is a collection of objects of a single type Each object in.
 2003 Prentice Hall, Inc. All rights reserved Basics of a Typical C++ Environment C++ systems –Program-development environment –Language –C++
1 8/30/06CS150 Introduction to Computer Science 1 Your First C++ Program.
Inheritance - 3. Virtual Functions Functions defined as virtual are ones that the base expects its derived classes may redefine. Functions defined as.
CHAPTER 3 COMPLETING THE PROBLEM- SOLVING PROCESS AND GETTING STARTED WITH C++ An Introduction to Programming with C++ Fifth Edition.
Prepared by Andrew Jung. Contents A Simple program – C++ C++ Standard Library & Header files Inline Functions References and Reference Parameters Empty.
Linux CSE 1222 CSE1222: Lecture 1BThe Ohio State University1.
STRUCTURED PROGRAMMING Complete C++ Program. Content 2  Main Function  Preprocessor directives  User comments  Escape characters  cout statement.
Chapter 15 - C++ As A "Better C"
Note: Some of the slides are repeated from Introduction to C++
Chapter 1.2 Introduction to C++ Programming
C++ Exceptions.
Chapter 1.2 Introduction to C++ Programming
Chapter 1.2 Introduction to C++ Programming
CMPT 201.
Chapter 1: Introduction to computers and C++ Programming
Chapter 2 Introduction to C++ Programming
ANNOUNCEMENT The missed lecture will be made up this Monday evening in the Tech PC classroom (MG51). A tentative time interval is 6:30-8:00. The exact.
Prog Club Introductory Presentation
Introduction to C++ Systems Programming.
CS-103 COMPUTER PROGRAMMING
Session 1 - Introduction
C++ Standard Library.
Beginning C++ Programming
1.13 The Key Software Trend: Object Technology
Introduction to C++ Programming
C++ Programming Lecture 3 C++ Basics – Part I
Programs written in C and C++ can run on many different computers
Lecture 2 Fall 2011 September 13-15, 2011 Ghufran Ahmed
CHAPTER 4 File Processing.
Capitolo 1 – Introduction C++ Programming
C++ Introduction - 3.
Std Library of C++.
COMS 261 Computer Science I
EECE.3220 Data Structures Instructor: Dr. Michael Geiger Spring 2019
Introduction to Programming - 1
Chapter 2 part #1 C++ Program Structure
Presentation transcript:

C++ Introduction

Why Learn C++? Very powerful and respected prog. Lang. Very powerful and respected prog. Lang. Highly respected in Academics Highly respected in Academics B. Tech./M.Tech. Project work B. Tech./M.Tech. Project work Job Written Test + Interview Job Written Test + Interview Research: Programming work can be done in C++ Research: Programming work can be done in C++

Only course in C++ This may be the only course in C++ done by you. This may be the only course in C++ done by you. So learn it well So learn it well Benefits, later on in life, can be enormous Benefits, later on in life, can be enormous Excellent Lab facilities Excellent Lab facilities Use extra Lab time whenever possible Use extra Lab time whenever possible But do not neglect other courses But do not neglect other courses

Course Book C++ Primer, Fourth Edition C++ Primer, Fourth Edition Authors: Authors: Stanley B. Lippman Stanley B. Lippman Josee Lajoie Josee Lajoie Barbara E. Moo Barbara E. Moo Publisher: Pearson Education Publisher: Pearson Education ISBN: ISBN: Price Price List Price: Rs. 475 List Price: Rs. 475 Discount: Usually 10 to 20% Discount: Usually 10 to 20%

Course Book - 2 Availability of hard copy enables: Availability of hard copy enables: Easy lookup and study Easy lookup and study Faster and better learning Faster and better learning At least one copy for two students is essential At least one copy for two students is essential Will be useful after course too Will be useful after course too Procure book quickly Procure book quickly Book covers both C and C++ Book covers both C and C++ Reading chapters of book will be very useful Reading chapters of book will be very useful

First C++ Program #include //Not iostream.h #include //Not iostream.h int main() int main() { std::cout << “Hello world\n”; std::cout << “Hello world\n”; }

First C++ Program – 2 C++ is a superset of C C++ is a superset of C Standard header files do not have.h typically Standard header files do not have.h typically The iostream header includes information about stream objects used for input and output. The iostream header includes information about stream objects used for input and output. All such stream objects are said to be part of the iostream library All such stream objects are said to be part of the iostream library Instead of printf we use std::cout Instead of printf we use std::cout

First C++ Program - 3 std is a namespace std is a namespace cout is an object which writes (outputs) to a stream (the terminal usually) cout is an object which writes (outputs) to a stream (the terminal usually) :: is required between namespace and object :: is required between namespace and object << is the way to direct data into cout object << is the way to direct data into cout object << is also called output operator << is also called output operator

First C++ Program - 4 Source code file extension should be.cpp Source code file extension should be.cpp Save file as firstpgm.cpp Save file as firstpgm.cpp Compile using c++ or g++ Compile using c++ or g++ Executable file is named as a.out Executable file is named as a.out

Second C++ Program Book code is available as a zip file Book code is available as a zip file Windows: files.zip Windows: files.zip Linux: files.tar.gz Linux: files.tar.gz Copy it to your system (on Linux) and unzip it Copy it to your system (on Linux) and unzip it Chapter 1, add.cc Chapter 1, add.cc.cc is also used as extension for C++ source files but you should only use.cpp while you are doing this course..cc is also used as extension for C++ source files but you should only use.cpp while you are doing this course.

Second C++ Program - 2 << output operator can be used multiple times in one statement << output operator can be used multiple times in one statement std::endl is another way of inserting a newline (\n) std::endl is another way of inserting a newline (\n) Defining int variables is same as C Defining int variables is same as C

Second C++ Program - 3 std::cin is an input stream object which usually reads from keyboard std::cin is an input stream object which usually reads from keyboard >> is the input operator which reads input and puts the input into variables on right hand side of operator >> is the input operator which reads input and puts the input into variables on right hand side of operator

Read Course Book Course book (C++ Primer 4/e) : Course book (C++ Primer 4/e) : Gives a lot of additional information far beyond what we have time to cover in class Gives a lot of additional information far beyond what we have time to cover in class Is somewhat precise and so may take getting used to Is somewhat precise and so may take getting used to

Read Course Book - 2 But it is very good and very accurate But it is very good and very accurate Has simple exercises Has simple exercises Has nice layout with certain paragraphs marked specially as Notes or Beware (warnings) Has nice layout with certain paragraphs marked specially as Notes or Beware (warnings) Reading and understanding it thoroughly will make you a thorough C++ Guru Reading and understanding it thoroughly will make you a thorough C++ Guru

Hands On (Finally ) Start your system Start your system Choose Red Hat Linux as OS (instead of default Windows) Choose Red Hat Linux as OS (instead of default Windows) Log on with userid: - and password: - Log on with userid: - and password: - Wait for the GUI (Graphical User Interface) to come up properly Wait for the GUI (Graphical User Interface) to come up properly Open a terminal window Open a terminal window

First Assignment Write the Hello World program using vi Write the Hello World program using vi Source file name must end in.cpp Source file name must end in.cpp Compile it using c++ or g++ Compile it using c++ or g++ Executable file will be a.out (like what cc does) Executable file will be a.out (like what cc does) Run./a.out Run./a.out

Second Assignment First copy the book code zip file onto your system First copy the book code zip file onto your system Unzip the file Unzip the file Now read 1/add.cc Now read 1/add.cc Then write a program which takes in four integral numbers and gives the average of them as output. Then write a program which takes in four integral numbers and gives the average of them as output.

Book Source Code Copyright Note The course book is C++ Primer, 4th Edition by Lippman, Lajoie and Moo. Any references in earlier files to source files, and use of code within those files, are of example code given in and/or along with the book. As these slides are freely accessible on the Internet, not-for-profit, and for educational purposes, based on the permission related statements in the source code, I have considered that permission has been granted to use them in these slides. The course book is C++ Primer, 4th Edition by Lippman, Lajoie and Moo. Any references in earlier files to source files, and use of code within those files, are of example code given in and/or along with the book. As these slides are freely accessible on the Internet, not-for-profit, and for educational purposes, based on the permission related statements in the source code, I have considered that permission has been granted to use them in these slides.