Learners Support Publications www.lsp4you.com Introduction to C++

Slides:



Advertisements
Similar presentations
C++ Introduction.
Advertisements

Objectives You should be able to describe: Introduction to Programming
Introduction to C++ Programming. A Simple Program: Print a Line of Text // My First C++ Program #include int main( ) { cout
 2003 Prentice Hall, Inc. All rights reserved. 1 Introduction to C++ Programming Outline History of C and C++ C++ Standard Library Object Technology Basics.
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.
Three types of computer languages
1 September 6, 2005CS150 Introduction to Computer Science I What Actions Do We Have Part 1 CS150 Introduction to Computer Science I.
1 Lecture 5: Input/Output (I) Introduction to Computer Science Spring 2006.
Chapter 8: Introduction to High-level Language Programming Invitation to Computer Science, C++ Version, Third Edition.
 2003 Prentice Hall, Inc. All rights reserved. 1 Machine Languages, Assembly Languages, and High-level Languages Three types of computer languages 1.Machine.
1 8/30/06CS150 Introduction to Computer Science 1 Your First C++ Program.
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++ fundamentals.
Programming is instructing a computer to perform a task for you with the help of a programming language.
Introduction to C++ Programming
Copyright 2003 Scott/Jones Publishing Brief Version of Starting Out with C++, 4th Edition Chapter 1 Introduction to Computers and Programming.
COMPUTER SCIENCE I C++ INTRODUCTION
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++
High-Level Programming Languages: C++
Introduction of C++ language. C++ Predecessors Early high level languages or programming languages were written to address a particular kind of computing.
C++ Basics Structure of a Program. C++ Source Code Plain text file Typical file extension .CPP Must compile the C++ source code without errors before.
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.
Computer Programming TCP1224 Chapter 3 Completing the Problem-Solving Process and Getting Started with C++
/* Documentations */ Pre process / Linking statements Global declarations; main( ) { Local Declarations; Program statements / Executable statements; }
C++ Programming: From Problem Analysis to Program Design, Fourth Edition Chapter 2: Basic Elements of C++
Rossella Lau Lecture 1, DCO10105, Semester B, DCO10105 Object-Oriented Programming and Design  Lecture 1: Introduction What this course is about:
 2008 Pearson Education, Inc. All rights reserved. 1 CISC 1600 – Computer Science I Fall 2010 Introduction to C++ Programming Chapters 1 and 2 (Deitel.
Object Oriented Programming with C++ Diploma in Computer System Design.
Programming Fundamentals. Today’s Lecture Why do we need Object Oriented Language C++ and C Basics of a typical C++ Environment Basic Program Construction.
Course Title: Introduction to C++ Course Instructor: ADEEL ANJUM Chapter No: 01 1 BY ADEEL ANJUM (MCS, CCNA,WEB DEVELOPER)
C++ Programming: Basic Elements of C++.
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 7 DATA INPUT OUTPUT Prepared by: Lec. Ghader R. Kurdi.
1 CS161 Introduction to Computer Science Topic #3.
C++ Basics #7 Basic Input and Output. In this video Standard output (cout) Standard input (cin) stringstream.
Introduction to C++ Basic Elements of C++. C++ Programming: From Problem Analysis to Program Design, Fourth Edition2 The Basics of a C++ Program Function:
THE BASICS OF A C++ PROGRAM EDP 4 / MATH 23 TTH 5:45 – 7:15.
C++ Programming Basic Learning Prepared By The Smartpath Information systems
Lecture #6 OPERATORS AND ITS TYPES By Shahid Naseem (Lecturer)
Basic Program Construction
Control Structures (B) Topics to cover here: Sequencing in C++ language.
1 Chapter 2 C++ Syntax and Semantics, and the Program Development Process.
1 COMS 261 Computer Science I Title: C++ Fundamentals Date: September 05, 2005 Lecture Number: 4.
CHAPTER 1: INTRODUCTION C++ Programming. CS 241 Course URL: Text Book: C++ How to Program, DETITEL & DEITEL, eighth Edition.
1 What is a Named Constant? A named constant is a location in memory that we can refer to by an identifier, and in which a data value that cannot be changed.
Brief Version of Starting Out with C++ Chapter 1 Introduction to Computers and Programming.
Course Title Object Oriented Programming with C++ instructor ADEEL ANJUM Chapter No: 03 Conditional statement 1 BY ADEEL ANJUM (MSc-cs, CCNA,WEB DEVELOPER)
Chapter 11  Getting ready to program  Hardware Model  Software Model  Programming Languages  Facts about C++  Program Development Process  The Hello-world.
Introduction. Natural Languages are languages of the Humans These Languages tend to be ambiguous A sentence in natural may not have just one meaning I.
Copyright © 2014 Pearson Addison-Wesley. All rights reserved. Chapter 2 C++ Basics.
 2003 Prentice Hall, Inc. All rights reserved Basics of a Typical C++ Environment C++ systems –Program-development environment –Language –C++
1 Structure of Simple C++ Program Chapter 1 09/09/13.
1 8/30/06CS150 Introduction to Computer Science 1 Your First C++ Program.
CHAPTER 3 COMPLETING THE PROBLEM- SOLVING PROCESS AND GETTING STARTED WITH C++ An Introduction to Programming with C++ Fifth Edition.
Intro. to Computer Programming Eng. Nehal A. Mohamed Spring Semester-2016.
PROGRAMMING WITH C ++.
Chapter 1.2 Introduction to C++ Programming
Chapter 1: Introduction to computers and C++ Programming
Chapter 1.2 Introduction to C++ Programming
Chapter 2 part #1 C++ Program Structure
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.
Beginning C++ Programming
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.
Programs written in C and C++ can run on many different computers
Lecture 2 Fall 2011 September 13-15, 2011 Ghufran Ahmed
Capitolo 1 – Introduction C++ Programming
Chapter 1 c++ structure C++ Input / Output
Presentation transcript:

Learners Support Publications Introduction to C++

Learners Support Publications Objectives of this session What is C++ What is C++ A Simple Program A Simple Program Comments in C++ Comments in C++ Output Operator Output Operator Input Operator Input Operator Cascading of I/O Operator Cascading of I/O Operator Structure of a C++ Program Structure of a C++ Program

Learners Support Publications C++ C++ is an object-oriented programming language. C++ is an object-oriented programming language. Developed by Bjarne Stroustrup at AT&T Bell Laboratories, USA in the early 1980’s. Developed by Bjarne Stroustrup at AT&T Bell Laboratories, USA in the early 1980’s. Simule 67 + C language  C++ Simule 67 + C language  C November ANSI/ISO standards committee standardised C November ANSI/ISO standards committee standardised C++. For developing editors, compilers, databases, communication systems, etc. For developing editors, compilers, databases, communication systems, etc.

Learners Support Publications A Simple Program C++ works by giving (separate) instructions to the computer. C++ works by giving (separate) instructions to the computer. These instructions can be written as functions. These instructions can be written as functions. The primary function used in C++ is called main. This means that every C++ program should have the main() function. Because a function is an assignment, in order to perform its job, a function has a body. The body of a function starts with an opening curly bracket "{" and closes with a closing curly bracket "}". The primary function used in C++ is called main. This means that every C++ program should have the main() function. Because a function is an assignment, in order to perform its job, a function has a body. The body of a function starts with an opening curly bracket "{" and closes with a closing curly bracket "}".

Learners Support Publications A Simple Program // my first program in C++ #include #include int main ( ) { cout << "Hello World!"; return 0; } Hello World! continue…

Learners Support Publications Comments in C++ The most basic documentation you have to perform is to put comments as much as you can. Comments help you and other people who read your code to figure out what you were doing. The most basic documentation you have to perform is to put comments as much as you can. Comments help you and other people who read your code to figure out what you were doing. Comments are not read by the compiler while executing your program. Comments are not read by the compiler while executing your program. C++ supports two ways to insert comments: C++ supports two ways to insert comments: o // line comment o /* block comment */

Learners Support Publications Comments in C++ // The hello.cpp program // Include the iostream library #include #include int main( ) { /* Here is a simple sentence that I want to display when the program starts. It doesn't do much. I am planning to do more stuff in the future. */ cout << "Hi, this is my program!"; return 0; } // The end of my program continue…

Learners Support Publications Output Operator cout << "Hi, this is my program!"; cout is a predefined object that represents the standard output stream in C++, here the standard output stream is screen. scree n cout << C++ variable ObjectInsertion Operator

Learners Support Publications Output Operator The operator << is called insertion or put to operator. The operator << is called insertion or put to operator. It inserts ( or sends ) the contents of the variable on its right to the object on its left. It inserts ( or sends ) the contents of the variable on its right to the object on its left. cout << "Hi, this is my program!"; cout << number ; scree n cout << C++ variable ObjectInsertion Operator continue…

Learners Support Publications Input Operator cin >> number1; cin is a predefined object that corresponds to the standard input stream in C++, here the standard input stream is keyboard. cin >> ObjectExtraction Operator C++ variable Keyboard

Learners Support Publications Input Operator The operator >> is known as extraction or get from operator. The operator >> is known as extraction or get from operator. It extracts ( or takes ) the value from the keyboard and assigns it to the variable on its right. It extracts ( or takes ) the value from the keyboard and assigns it to the variable on its right. cin >> ObjectExtraction Operator C++ variable Keyboard continue…

Learners Support Publications Cascading of I/O Operators Multiple use of > in one statement is called cascading. Multiple use of > in one statement is called cascading.eg:- cout << “Sum = ” << sum << “\n”; cin >> number1 >> number2;

Learners Support Publications Structure of a C++ Program Better to organize a program file into three separate files. o Class declarations in a header file. o Definition of member function in a separate file. o The main program that uses the class is placed in a third file which includes the previous two files. Include files Class declaration Member functions declaration Main function program