SlideShare a Scribd company logo
1 of 6
Download to read offline
A SIMPLE PROGRAM TO PRINT
A LINE OF TEXT
Lecture 1.3
Prepared by: Mian Saeed Akbar
REF:
1 // A first program in C++.
3 #include <iostream>
4
5 // function main begins program execution
6 int main()
7 {
8 std::cout << "Welcome to C++!n";
9
10 return 0; // indicate that program ended successfully
11
12 } // end function main
Welcome to C++!
Single-line comments.
Preprocessor directive to
include input/output stream
header file <iostream>.
Function main appears
exactly once in every C++
program..
Function main returns an
integer value.
Left brace { begins function
body.
Corresponding right brace }
ends function body.
Statements end with a
semicolon ;.
Name cout belongs to
namespace std.
Stream insertion operator.
Keyword return is one of
several means to exit
function; value 0 indicates
program terminated
successfully.
A SIMPLE PROGRAM TO PRINT A LINE OF TEXT
Before writing the programs
Comments
 Document programs
 Improve program readability
 Ignored by compiler
 Single-line comment
 Use C’s comment /* .. */ OR Begin with //
Preprocessor directives
 Processed by preprocessor before compiling
 Begin with #
A SIMPLE PROGRAM TO PRINT A LINE OF TEXT
Common Input/output functions
cin
 Standard input stream
 Normally keyboard
cout
 Standard output stream
 Normally computer screen
cerr
 Standard error stream
 Display error messages
A SIMPLE PROGRAM TO PRINT A LINE OF TEXT
Standard output stream object
 std::cout
 “Connected” to screen
 <<
 Stream insertion operator
 Value to right (right operand) inserted into output stream
Namespace
 std:: specifies using name that belongs to “namespace” std
 std:: removed through use of using statements
Escape characters
 
 Indicates “special” character output
Thank you
Please subscribe my channel for more videos
and courses

More Related Content

Similar to Lecture 1.3 A Simple Program to Print a Line of Text.pdf

Introduction to C++ lecture ************
Introduction to C++ lecture ************Introduction to C++ lecture ************
Introduction to C++ lecture ************Emad Helal
 
Chapter 2 - Structure of C++ Program
Chapter 2 - Structure of C++ ProgramChapter 2 - Structure of C++ Program
Chapter 2 - Structure of C++ ProgramDeepak Singh
 
Ch2 C Fundamentals
Ch2 C FundamentalsCh2 C Fundamentals
Ch2 C FundamentalsSzeChingChen
 
INTRODUCTION TO C PROGRAMMING MATERIAL.pdf
INTRODUCTION TO C PROGRAMMING MATERIAL.pdfINTRODUCTION TO C PROGRAMMING MATERIAL.pdf
INTRODUCTION TO C PROGRAMMING MATERIAL.pdfSubramanyambharathis
 
8.3 program structure (1 hour)
8.3 program structure (1 hour)8.3 program structure (1 hour)
8.3 program structure (1 hour)akmalfahmi
 
visualbasicprograming
visualbasicprogramingvisualbasicprograming
visualbasicprogramingdhi her
 
Program structure of c
Program structure of cProgram structure of c
Program structure of cSatveer Mann
 
My first program in c, hello world !
My first program in c, hello world !My first program in c, hello world !
My first program in c, hello world !Rumman Ansari
 
Labsheet1 stud
Labsheet1 studLabsheet1 stud
Labsheet1 studrohassanie
 
Introduction of c language
Introduction of c languageIntroduction of c language
Introduction of c languagefarishah
 
C Programming UNIT 1.pptx
C Programming  UNIT 1.pptxC Programming  UNIT 1.pptx
C Programming UNIT 1.pptxMugilvannan11
 
Introduction to cpp language and all the required information relating to it
Introduction to cpp language and all the required information relating to itIntroduction to cpp language and all the required information relating to it
Introduction to cpp language and all the required information relating to itPushkarNiroula1
 

Similar to Lecture 1.3 A Simple Program to Print a Line of Text.pdf (20)

Introduction to C++ lecture ************
Introduction to C++ lecture ************Introduction to C++ lecture ************
Introduction to C++ lecture ************
 
Cp week _2.
Cp week _2.Cp week _2.
Cp week _2.
 
Chapter 2 - Structure of C++ Program
Chapter 2 - Structure of C++ ProgramChapter 2 - Structure of C++ Program
Chapter 2 - Structure of C++ Program
 
Ch2 C Fundamentals
Ch2 C FundamentalsCh2 C Fundamentals
Ch2 C Fundamentals
 
C PROGRAMMING p-2.pdf
C PROGRAMMING p-2.pdfC PROGRAMMING p-2.pdf
C PROGRAMMING p-2.pdf
 
INTRODUCTION TO C PROGRAMMING MATERIAL.pdf
INTRODUCTION TO C PROGRAMMING MATERIAL.pdfINTRODUCTION TO C PROGRAMMING MATERIAL.pdf
INTRODUCTION TO C PROGRAMMING MATERIAL.pdf
 
8.3 program structure (1 hour)
8.3 program structure (1 hour)8.3 program structure (1 hour)
8.3 program structure (1 hour)
 
Common Programming Errors
Common Programming ErrorsCommon Programming Errors
Common Programming Errors
 
visualbasicprograming
visualbasicprogramingvisualbasicprograming
visualbasicprograming
 
OVERVIEW OF ‘C’ PROGRAM
OVERVIEW OF ‘C’ PROGRAMOVERVIEW OF ‘C’ PROGRAM
OVERVIEW OF ‘C’ PROGRAM
 
Program structure of c
Program structure of cProgram structure of c
Program structure of c
 
My first program in c, hello world !
My first program in c, hello world !My first program in c, hello world !
My first program in c, hello world !
 
Labsheet1 stud
Labsheet1 studLabsheet1 stud
Labsheet1 stud
 
1-intro.pdf
1-intro.pdf1-intro.pdf
1-intro.pdf
 
Introduction of c language
Introduction of c languageIntroduction of c language
Introduction of c language
 
C++ basics
C++ basicsC++ basics
C++ basics
 
Prog1-L1.pdf
Prog1-L1.pdfProg1-L1.pdf
Prog1-L1.pdf
 
C Programming UNIT 1.pptx
C Programming  UNIT 1.pptxC Programming  UNIT 1.pptx
C Programming UNIT 1.pptx
 
C Fundamental.docx
C Fundamental.docxC Fundamental.docx
C Fundamental.docx
 
Introduction to cpp language and all the required information relating to it
Introduction to cpp language and all the required information relating to itIntroduction to cpp language and all the required information relating to it
Introduction to cpp language and all the required information relating to it
 

More from MianSaeedAkbar1

Lecture 2.2 Default Arguments.pdf
Lecture 2.2 Default Arguments.pdfLecture 2.2 Default Arguments.pdf
Lecture 2.2 Default Arguments.pdfMianSaeedAkbar1
 
Lecture 2.6 Function Templates.pdf
Lecture 2.6 Function Templates.pdfLecture 2.6 Function Templates.pdf
Lecture 2.6 Function Templates.pdfMianSaeedAkbar1
 
Lecture 2.4 Recursion.pdf
Lecture 2.4 Recursion.pdfLecture 2.4 Recursion.pdf
Lecture 2.4 Recursion.pdfMianSaeedAkbar1
 
Lecture 3 Structures in C++.pdf
Lecture 3 Structures in C++.pdfLecture 3 Structures in C++.pdf
Lecture 3 Structures in C++.pdfMianSaeedAkbar1
 
Lecture 2.5 Function Overloading.pdf
Lecture 2.5 Function Overloading.pdfLecture 2.5 Function Overloading.pdf
Lecture 2.5 Function Overloading.pdfMianSaeedAkbar1
 
Lecture 1.11 Break and Continue Statements.pdf
Lecture 1.11 Break and Continue Statements.pdfLecture 1.11 Break and Continue Statements.pdf
Lecture 1.11 Break and Continue Statements.pdfMianSaeedAkbar1
 
Lecture 2.1 Functions.pdf
Lecture 2.1 Functions.pdfLecture 2.1 Functions.pdf
Lecture 2.1 Functions.pdfMianSaeedAkbar1
 
Lecture 1.5 Variables.pdf
Lecture 1.5 Variables.pdfLecture 1.5 Variables.pdf
Lecture 1.5 Variables.pdfMianSaeedAkbar1
 
Lecture 1.2 Basics of a typical C++ Environment.pdf
Lecture 1.2 Basics of a typical C++ Environment.pdfLecture 1.2 Basics of a typical C++ Environment.pdf
Lecture 1.2 Basics of a typical C++ Environment.pdfMianSaeedAkbar1
 
Lecture 2.3 Inline Function.pdf
Lecture 2.3 Inline Function.pdfLecture 2.3 Inline Function.pdf
Lecture 2.3 Inline Function.pdfMianSaeedAkbar1
 
Lecture 1.8 Conditional Structures.pdf
Lecture 1.8 Conditional Structures.pdfLecture 1.8 Conditional Structures.pdf
Lecture 1.8 Conditional Structures.pdfMianSaeedAkbar1
 
Lecture 2.7 Type Conversion in C++.pdf
Lecture 2.7 Type Conversion in C++.pdfLecture 2.7 Type Conversion in C++.pdf
Lecture 2.7 Type Conversion in C++.pdfMianSaeedAkbar1
 
Lecture 1.6 Arithmetic and Relational Operators.pdf
Lecture 1.6 Arithmetic and Relational Operators.pdfLecture 1.6 Arithmetic and Relational Operators.pdf
Lecture 1.6 Arithmetic and Relational Operators.pdfMianSaeedAkbar1
 
Lecture 1.7 C++ Keywords.pdf
Lecture 1.7 C++ Keywords.pdfLecture 1.7 C++ Keywords.pdf
Lecture 1.7 C++ Keywords.pdfMianSaeedAkbar1
 
Lecture 1.4 Escape Sequence.pdf
Lecture 1.4 Escape Sequence.pdfLecture 1.4 Escape Sequence.pdf
Lecture 1.4 Escape Sequence.pdfMianSaeedAkbar1
 
Lecture 1.9 Switch Structure.pdf
Lecture 1.9 Switch Structure.pdfLecture 1.9 Switch Structure.pdf
Lecture 1.9 Switch Structure.pdfMianSaeedAkbar1
 
Lecture 1.10 Repetition Structures.pdf
Lecture 1.10 Repetition Structures.pdfLecture 1.10 Repetition Structures.pdf
Lecture 1.10 Repetition Structures.pdfMianSaeedAkbar1
 
Lecture 0 Object Oriented Programming.pdf
Lecture 0 Object Oriented Programming.pdfLecture 0 Object Oriented Programming.pdf
Lecture 0 Object Oriented Programming.pdfMianSaeedAkbar1
 
Lecture 1.1 Introduction to Computer Languages.pdf
Lecture 1.1 Introduction to Computer Languages.pdfLecture 1.1 Introduction to Computer Languages.pdf
Lecture 1.1 Introduction to Computer Languages.pdfMianSaeedAkbar1
 

More from MianSaeedAkbar1 (20)

Lecture 2.8 Arrays.pdf
Lecture 2.8 Arrays.pdfLecture 2.8 Arrays.pdf
Lecture 2.8 Arrays.pdf
 
Lecture 2.2 Default Arguments.pdf
Lecture 2.2 Default Arguments.pdfLecture 2.2 Default Arguments.pdf
Lecture 2.2 Default Arguments.pdf
 
Lecture 2.6 Function Templates.pdf
Lecture 2.6 Function Templates.pdfLecture 2.6 Function Templates.pdf
Lecture 2.6 Function Templates.pdf
 
Lecture 2.4 Recursion.pdf
Lecture 2.4 Recursion.pdfLecture 2.4 Recursion.pdf
Lecture 2.4 Recursion.pdf
 
Lecture 3 Structures in C++.pdf
Lecture 3 Structures in C++.pdfLecture 3 Structures in C++.pdf
Lecture 3 Structures in C++.pdf
 
Lecture 2.5 Function Overloading.pdf
Lecture 2.5 Function Overloading.pdfLecture 2.5 Function Overloading.pdf
Lecture 2.5 Function Overloading.pdf
 
Lecture 1.11 Break and Continue Statements.pdf
Lecture 1.11 Break and Continue Statements.pdfLecture 1.11 Break and Continue Statements.pdf
Lecture 1.11 Break and Continue Statements.pdf
 
Lecture 2.1 Functions.pdf
Lecture 2.1 Functions.pdfLecture 2.1 Functions.pdf
Lecture 2.1 Functions.pdf
 
Lecture 1.5 Variables.pdf
Lecture 1.5 Variables.pdfLecture 1.5 Variables.pdf
Lecture 1.5 Variables.pdf
 
Lecture 1.2 Basics of a typical C++ Environment.pdf
Lecture 1.2 Basics of a typical C++ Environment.pdfLecture 1.2 Basics of a typical C++ Environment.pdf
Lecture 1.2 Basics of a typical C++ Environment.pdf
 
Lecture 2.3 Inline Function.pdf
Lecture 2.3 Inline Function.pdfLecture 2.3 Inline Function.pdf
Lecture 2.3 Inline Function.pdf
 
Lecture 1.8 Conditional Structures.pdf
Lecture 1.8 Conditional Structures.pdfLecture 1.8 Conditional Structures.pdf
Lecture 1.8 Conditional Structures.pdf
 
Lecture 2.7 Type Conversion in C++.pdf
Lecture 2.7 Type Conversion in C++.pdfLecture 2.7 Type Conversion in C++.pdf
Lecture 2.7 Type Conversion in C++.pdf
 
Lecture 1.6 Arithmetic and Relational Operators.pdf
Lecture 1.6 Arithmetic and Relational Operators.pdfLecture 1.6 Arithmetic and Relational Operators.pdf
Lecture 1.6 Arithmetic and Relational Operators.pdf
 
Lecture 1.7 C++ Keywords.pdf
Lecture 1.7 C++ Keywords.pdfLecture 1.7 C++ Keywords.pdf
Lecture 1.7 C++ Keywords.pdf
 
Lecture 1.4 Escape Sequence.pdf
Lecture 1.4 Escape Sequence.pdfLecture 1.4 Escape Sequence.pdf
Lecture 1.4 Escape Sequence.pdf
 
Lecture 1.9 Switch Structure.pdf
Lecture 1.9 Switch Structure.pdfLecture 1.9 Switch Structure.pdf
Lecture 1.9 Switch Structure.pdf
 
Lecture 1.10 Repetition Structures.pdf
Lecture 1.10 Repetition Structures.pdfLecture 1.10 Repetition Structures.pdf
Lecture 1.10 Repetition Structures.pdf
 
Lecture 0 Object Oriented Programming.pdf
Lecture 0 Object Oriented Programming.pdfLecture 0 Object Oriented Programming.pdf
Lecture 0 Object Oriented Programming.pdf
 
Lecture 1.1 Introduction to Computer Languages.pdf
Lecture 1.1 Introduction to Computer Languages.pdfLecture 1.1 Introduction to Computer Languages.pdf
Lecture 1.1 Introduction to Computer Languages.pdf
 

Recently uploaded

Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibitjbellavia9
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and ModificationsMJDuyan
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsKarakKing
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxRamakrishna Reddy Bijjam
 
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdfVishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdfssuserdda66b
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxJisc
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxVishalSingh1417
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxcallscotland1987
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxEsquimalt MFRC
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...Poonam Aher Patil
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxAreebaZafar22
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Jisc
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxAmanpreet Kaur
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - Englishneillewis46
 

Recently uploaded (20)

Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdfVishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptx
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 

Lecture 1.3 A Simple Program to Print a Line of Text.pdf

  • 1. A SIMPLE PROGRAM TO PRINT A LINE OF TEXT Lecture 1.3 Prepared by: Mian Saeed Akbar REF:
  • 2. 1 // A first program in C++. 3 #include <iostream> 4 5 // function main begins program execution 6 int main() 7 { 8 std::cout << "Welcome to C++!n"; 9 10 return 0; // indicate that program ended successfully 11 12 } // end function main Welcome to C++! Single-line comments. Preprocessor directive to include input/output stream header file <iostream>. Function main appears exactly once in every C++ program.. Function main returns an integer value. Left brace { begins function body. Corresponding right brace } ends function body. Statements end with a semicolon ;. Name cout belongs to namespace std. Stream insertion operator. Keyword return is one of several means to exit function; value 0 indicates program terminated successfully.
  • 3. A SIMPLE PROGRAM TO PRINT A LINE OF TEXT Before writing the programs Comments  Document programs  Improve program readability  Ignored by compiler  Single-line comment  Use C’s comment /* .. */ OR Begin with // Preprocessor directives  Processed by preprocessor before compiling  Begin with #
  • 4. A SIMPLE PROGRAM TO PRINT A LINE OF TEXT Common Input/output functions cin  Standard input stream  Normally keyboard cout  Standard output stream  Normally computer screen cerr  Standard error stream  Display error messages
  • 5. A SIMPLE PROGRAM TO PRINT A LINE OF TEXT Standard output stream object  std::cout  “Connected” to screen  <<  Stream insertion operator  Value to right (right operand) inserted into output stream Namespace  std:: specifies using name that belongs to “namespace” std  std:: removed through use of using statements Escape characters   Indicates “special” character output
  • 6. Thank you Please subscribe my channel for more videos and courses