SlideShare a Scribd company logo
1 of 10
C++ PROGRAMMING
Introduction to
// my first program in C++
#include <iostream>
int main()
{
std::cout << "Hello World!";
}
Structure of a Program
Line 1: // my first program in C++
Two slash signs indicate that the rest of the line is
a comment inserted by the programmer but which has
no effect on the behavior of the program. Programmers
use them to include short explanations or observations
concerning the code or program. In this case, it is a brief
introductory description of the program.
Structure of a Program
• A Compiler is a computer program that transforms
program code written in a programming language into
another computer language.
• A Directive is a language construct that specifies how a
compiler should process its input.
• A Preprocessor is a program that processes its input data
to produce output that is used as input to another
program.
Structure of a Program
Line 2: #include <iostream>
Lines beginning with a hash sign (#) are directives read and
interpreted by what is known as the preprocessor. They are special lines
interpreted before the compilation of the program itself begins. In this
case, the directive #include <iostream>, instructs the preprocessor to
include a section of standard C++ code, known as header iostream, that
allows to perform standard input and output operations, such as writing
the output of this program (Hello World) to the screen.
Structure of a Program
Line 3: using namespace std;
namespace is a library of codes in c++ that is
included in c++ programs in able to use cout and cin
statements.
Structure of a Program
Line 4: A blank line.
Blank lines have no effect on a program. They
simply improve readability of the code
Structure of a Program
Line 5: int main ()
This line initiates the declaration of a function. Essentially, a function
is a group of code statements which are given a name: in this case, this gives
the name "main" to the group of code statements that follow. Functions are
introduced with a succession of a type (int), a name (main) and a pair of
parentheses ().
The function named main is a special function in all C++ programs; it
is the function called when the program is run. The execution of all C++
programs begins with the main function, regardless of where the function is
actually located within the code.
Structure of a Program
Lines 6 and 9: { and }
The open brace ({) at line 6 indicates the
beginning of main's function definition, and the closing
brace (}) at line 9, indicates its end. Everything between
these braces is the function's body that defines what
happens when main is called. All functions use braces to
indicate the beginning and end of their definitions.
Structure of a Program
Line 7 and 8: cout << "Hello World!";
This line is a C++ statement. A statement is an expression that can actually produce some
effect. It is the meat of a program, specifying its actual behavior. Statements are executed in the
same order that they appear within a function's body.
This statement has three parts: First, cout, which identifies
the standard character output device (usually, this is the computer screen). Second, the insertion
operator (<<), which indicates that what follows is inserted into cout. Finally, a sentence within
quotes ("Hello world!"), is the content inserted into the standard output.
Notice that the statement ends with a semicolon (;). This character marks the end of the
statement, just as the period ends a sentence in English. All C++ statements must end with a
semicolon character. One of the most common syntax errors in C++ is forgetting to end a statement
with a semicolon.
Structure of a Program
Comments do not affect the operation of the program; however, they
provide an important tool to document directly within the source code what
the program does and how it operates.
The first of them, known as line comment, discards everything from
where the pair of slash signs (//) are found up to the end of that same line. The
second one, known as block comment, discards everything between
the /* characters and the first appearance of the */ characters, with the
possibility of including multiple lines.

More Related Content

What's hot

What's hot (20)

C Program Structure
C Program StructureC Program Structure
C Program Structure
 
C languaGE UNIT-1
C languaGE UNIT-1C languaGE UNIT-1
C languaGE UNIT-1
 
C Language
C LanguageC Language
C Language
 
Basic construction of c
Basic construction of cBasic construction of c
Basic construction of c
 
The C++ Programming Language
The C++ Programming LanguageThe C++ Programming Language
The C++ Programming Language
 
Std 10 computer chapter 10 introduction to c language (part1)
Std 10 computer chapter 10 introduction to c language (part1)Std 10 computer chapter 10 introduction to c language (part1)
Std 10 computer chapter 10 introduction to c language (part1)
 
Steps for c program execution
Steps for c program executionSteps for c program execution
Steps for c program execution
 
Computer programming chapter ( 3 )
Computer programming chapter ( 3 ) Computer programming chapter ( 3 )
Computer programming chapter ( 3 )
 
C++ Tutorial
C++ TutorialC++ Tutorial
C++ Tutorial
 
C introduction
C introductionC introduction
C introduction
 
1.1 programming fundamentals
1.1 programming fundamentals1.1 programming fundamentals
1.1 programming fundamentals
 
3.2
3.23.2
3.2
 
Lecture 1
Lecture 1Lecture 1
Lecture 1
 
Apa style-1 (1)
Apa style-1 (1)Apa style-1 (1)
Apa style-1 (1)
 
C basics
C   basicsC   basics
C basics
 
Introduction to programming with c,
Introduction to programming with c,Introduction to programming with c,
Introduction to programming with c,
 
First session quiz
First session quizFirst session quiz
First session quiz
 
Compiler
Compiler Compiler
Compiler
 
over all view programming to computer
over all view programming to computer over all view programming to computer
over all view programming to computer
 
Introduction to c programming
Introduction to c programmingIntroduction to c programming
Introduction to c programming
 

Similar to Intro to c++

C language introduction geeksfor geeks
C language introduction   geeksfor geeksC language introduction   geeksfor geeks
C language introduction geeksfor geeks
AashutoshChhedavi
 
Chapter 2 - Structure of C++ Program
Chapter 2 - Structure of C++ ProgramChapter 2 - Structure of C++ Program
Chapter 2 - Structure of C++ Program
Deepak Singh
 

Similar to Intro to c++ (20)

C language introduction geeksfor geeks
C language introduction   geeksfor geeksC language introduction   geeksfor geeks
C language introduction geeksfor geeks
 
ProgFund_Lecture_7_Intro_C_Sequence.pdf
ProgFund_Lecture_7_Intro_C_Sequence.pdfProgFund_Lecture_7_Intro_C_Sequence.pdf
ProgFund_Lecture_7_Intro_C_Sequence.pdf
 
Basics Of C++.pptx
Basics Of C++.pptxBasics Of C++.pptx
Basics Of C++.pptx
 
Chapter 2 - Structure of C++ Program
Chapter 2 - Structure of C++ ProgramChapter 2 - Structure of C++ Program
Chapter 2 - Structure of C++ Program
 
Bcsl 031 solve assignment
Bcsl 031 solve assignmentBcsl 031 solve assignment
Bcsl 031 solve assignment
 
C programming course material
C programming course materialC programming course material
C programming course material
 
lecture1 pf.pptx
lecture1 pf.pptxlecture1 pf.pptx
lecture1 pf.pptx
 
Tutorial basic of c ++lesson 1 eng ver
Tutorial basic of c ++lesson 1 eng verTutorial basic of c ++lesson 1 eng ver
Tutorial basic of c ++lesson 1 eng ver
 
Introduction of c language
Introduction of c languageIntroduction of c language
Introduction of c language
 
C lecture notes new
C lecture notes newC lecture notes new
C lecture notes new
 
Intro To C++ - Class 3 - Sample Program
Intro To C++ - Class 3 - Sample ProgramIntro To C++ - Class 3 - Sample Program
Intro To C++ - Class 3 - Sample Program
 
Intro To C++ - Class 03 - An Introduction To C++ Programming, Part II
Intro To C++ - Class 03 - An Introduction To C++ Programming, Part IIIntro To C++ - Class 03 - An Introduction To C++ Programming, Part II
Intro To C++ - Class 03 - An Introduction To C++ Programming, Part II
 
Common Programming Errors
Common Programming ErrorsCommon Programming Errors
Common Programming Errors
 
Programming Fundamentals lecture 5
Programming Fundamentals lecture 5Programming Fundamentals lecture 5
Programming Fundamentals lecture 5
 
A tutorial on C++ Programming
A tutorial on C++ ProgrammingA tutorial on C++ Programming
A tutorial on C++ Programming
 
Lecture 1
Lecture 1Lecture 1
Lecture 1
 
C++ AND CATEGORIES OF SOFTWARE
C++ AND CATEGORIES OF SOFTWAREC++ AND CATEGORIES OF SOFTWARE
C++ AND CATEGORIES OF SOFTWARE
 
Basic c programming and explanation PPT1
Basic c programming and explanation PPT1Basic c programming and explanation PPT1
Basic c programming and explanation PPT1
 
CC 3 - Module 2.pdf
CC 3 - Module 2.pdfCC 3 - Module 2.pdf
CC 3 - Module 2.pdf
 
Beginner C++ easy slide and simple definition with questions
Beginner C++ easy slide and simple definition with questions Beginner C++ easy slide and simple definition with questions
Beginner C++ easy slide and simple definition with questions
 

More from Rafael Balderosa (12)

Grade 10 flowcharting
Grade 10  flowchartingGrade 10  flowcharting
Grade 10 flowcharting
 
Grade 10 program development cycle
Grade 10   program development cycleGrade 10   program development cycle
Grade 10 program development cycle
 
Grade 10 introduction and history of programming
Grade 10   introduction and history of programmingGrade 10   introduction and history of programming
Grade 10 introduction and history of programming
 
Cybercrime law
Cybercrime lawCybercrime law
Cybercrime law
 
Netiquette
NetiquetteNetiquette
Netiquette
 
If and nested if statements
If and nested if statementsIf and nested if statements
If and nested if statements
 
Grade 9 netiquette
Grade 9  netiquetteGrade 9  netiquette
Grade 9 netiquette
 
Grade 8 composition techniques
Grade 8   composition techniquesGrade 8   composition techniques
Grade 8 composition techniques
 
Grade 8 image file format
Grade 8   image file formatGrade 8   image file format
Grade 8 image file format
 
Grade 7 elements of computer system
Grade 7  elements of computer systemGrade 7  elements of computer system
Grade 7 elements of computer system
 
Grade 7 computer software
Grade 7  computer softwareGrade 7  computer software
Grade 7 computer software
 
Grade 7 history of internet
Grade 7   history of internetGrade 7   history of internet
Grade 7 history of internet
 

Recently uploaded

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
QucHHunhnh
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
Chris Hunter
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
heathfieldcps1
 
An Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfAn Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdf
SanaAli374401
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
kauryashika82
 

Recently uploaded (20)

Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
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
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
An Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfAn Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdf
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 

Intro to c++

  • 1. C++ PROGRAMMING Introduction to // my first program in C++ #include <iostream> int main() { std::cout << "Hello World!"; }
  • 2. Structure of a Program Line 1: // my first program in C++ Two slash signs indicate that the rest of the line is a comment inserted by the programmer but which has no effect on the behavior of the program. Programmers use them to include short explanations or observations concerning the code or program. In this case, it is a brief introductory description of the program.
  • 3. Structure of a Program • A Compiler is a computer program that transforms program code written in a programming language into another computer language. • A Directive is a language construct that specifies how a compiler should process its input. • A Preprocessor is a program that processes its input data to produce output that is used as input to another program.
  • 4. Structure of a Program Line 2: #include <iostream> Lines beginning with a hash sign (#) are directives read and interpreted by what is known as the preprocessor. They are special lines interpreted before the compilation of the program itself begins. In this case, the directive #include <iostream>, instructs the preprocessor to include a section of standard C++ code, known as header iostream, that allows to perform standard input and output operations, such as writing the output of this program (Hello World) to the screen.
  • 5. Structure of a Program Line 3: using namespace std; namespace is a library of codes in c++ that is included in c++ programs in able to use cout and cin statements.
  • 6. Structure of a Program Line 4: A blank line. Blank lines have no effect on a program. They simply improve readability of the code
  • 7. Structure of a Program Line 5: int main () This line initiates the declaration of a function. Essentially, a function is a group of code statements which are given a name: in this case, this gives the name "main" to the group of code statements that follow. Functions are introduced with a succession of a type (int), a name (main) and a pair of parentheses (). The function named main is a special function in all C++ programs; it is the function called when the program is run. The execution of all C++ programs begins with the main function, regardless of where the function is actually located within the code.
  • 8. Structure of a Program Lines 6 and 9: { and } The open brace ({) at line 6 indicates the beginning of main's function definition, and the closing brace (}) at line 9, indicates its end. Everything between these braces is the function's body that defines what happens when main is called. All functions use braces to indicate the beginning and end of their definitions.
  • 9. Structure of a Program Line 7 and 8: cout << "Hello World!"; This line is a C++ statement. A statement is an expression that can actually produce some effect. It is the meat of a program, specifying its actual behavior. Statements are executed in the same order that they appear within a function's body. This statement has three parts: First, cout, which identifies the standard character output device (usually, this is the computer screen). Second, the insertion operator (<<), which indicates that what follows is inserted into cout. Finally, a sentence within quotes ("Hello world!"), is the content inserted into the standard output. Notice that the statement ends with a semicolon (;). This character marks the end of the statement, just as the period ends a sentence in English. All C++ statements must end with a semicolon character. One of the most common syntax errors in C++ is forgetting to end a statement with a semicolon.
  • 10. Structure of a Program Comments do not affect the operation of the program; however, they provide an important tool to document directly within the source code what the program does and how it operates. The first of them, known as line comment, discards everything from where the pair of slash signs (//) are found up to the end of that same line. The second one, known as block comment, discards everything between the /* characters and the first appearance of the */ characters, with the possibility of including multiple lines.