SlideShare a Scribd company logo
1 of 29
1
1
Khawaja Sharif Sediqi
Basics of C++
Programming Language
C++
• C++ is a general-purpose programing
language.
• C++ is used to create computer programs
Anything from application , Music players and
even video gamest.
3
i C++ was derived from C, and is largely based on it
C++ is a:
General purpose programing language
Movie making program
Client-side scripting language
4
C++ is a:
General purpose programing language
Movie making program
Client-side scripting language
5
main
Source code
1. // my first program in C++
2. # include <iostream>
3.
4. int main ()
5. {
6. std::cout<<“Hello Word!”;
7. }
Output
Hello Word!
6
Program execution begin with the main function ,Int main().
main
• Curly brackets { } indicate the beginning and
end of function, which can also be called the
function’s body.
• The information inside the brackets indicates
what the function does when executed.
7
i
The entry point of every C++ program is main(),
irrespective of what the program does.
What is the starting point for a computer program?
main function
from <iostream>
first line
8
What is the starting point for a computer program?
main function
from <iostream>
first line
9
Your first C++ program
1. # include <iostream>
2.
3. int main ()
4. {
5. std::cout<<“Hello Word!”;
6. }
Hello Word!
10
The next line, Cout<<“Hello world !”; result in the display of “hello world “
to the screen.
Your first C++ program
• In C++ Stream are used to perform input and out put operations.
• In the most program environments, the standard default output
destination is the screen .
• in C++ cout is the stream object used to access it.
• Cout is used in combination with the insertion operator
• Writ the insertion operator as << to insert the data that comes after it
into the stream that comes before.
11
i
In C++ , the semicolon is used to terminate a statement.
Each statement must end with a semicolon . It indicate the
end of one logical expression.
Each instruction must end with a
dot ( . )
Comma ( , )
Colon ( : )
Semicolon ( ; )
12
Each instruction must end with a
dot ( . )
Comma ( , )
Colon ( : )
Semicolon ( ; )
13
Statement
• A block is a set of logical connected
statements, surrounded by opening and closing
curly braces
1. {
2. cout<<“Hello Word!”;
return 0;
3. }
14
i
You can have multiple statement on a single line, as long as
you remember to end each statement with a semicolon .
Failing to do so will result in an error
Components of a C++ program
You can add multiple insertion operation after
cout
1. {
2. cout<<“This” << “awesome!”;
return 0;
3. }
15
New Line
The cout operator does not insert a line break at
the end of the output.
Own a way to print two line is to use the endl
manipulator , which will put a line break
1. {
2. cout<<“Hello” << endl ;
3.cout<< “My name is Ahmad!”;
return 0;
4. } 16
What should be used to move to an new line
start
#include
endl
next line
17
New Lines
The new line character n can be used as an
alternative to endl.
The backslash () is called an escape character
and indicate a “special” character.
1. {
2. cout<<“welcome n” ;
3.cout<< “My name is Ahmad!”;
return 0;
4. } 18
What is symbol for moving to a new line( alternative
to the endl)
a
n
b
19
What is symbol for moving to a new line( alternative
to the endl)
a
n
b
20
Comments
Comments are explanatory statement that you
can include in the C++ code to explain what the
code is doing.
The compiler ignores everything that appears int
the comment.so none of that information shows in
the result.
A comment beginning with two slashes (//) is
called single-line comment.
The slashes tell the compiler to ignore everything
that follows.
until the end of the line
21
Comment
1. # include <iostream>
2. using namespace std;
3. //std is declaration region
4. int main ()
5. {
6. //pring “hello world”
7. cout<<“Hello Word!”;
8. return 0;
9. }
Hello Word!
22
When the following code is compiled , it will ignore the
// prints “ hello world” statement and will produce the following result.
Which choice indicate a signal-line comment
// single line comment
** single line comment
##single the comment
23
Which choice indicate a signal-line comment
// single line comment
** single line comment
##single the comment
24
Multi-Line Comments
Comment that require multiple lines begin with
/* and end with */
You can place them on the same line or insert
one or more lines between them.
/* This is a comment */
/* C++ comments can
Span multiple lines
*/
25
Create a block comment ( multiline comment) in C+
+
This is a block /multiline
Comment in C++
26
Create a block comment ( multiline comment) in C+
+
This is a block /multiline
Comment in C++
27
/*
*/
Which of the following in true
Comments are ignored by the compiler
Comments are used to confuse programmers
single line comments starts with an *
28
Which of the following in true
Comments are ignored by the compiler
Comments are used to confuse programmers
single line comments starts with an *
29

More Related Content

What's hot

basics of C and c++ by eteaching
basics of C and c++ by eteachingbasics of C and c++ by eteaching
basics of C and c++ by eteachingeteaching
 
Learning C++ - Introduction to c++ programming 1
Learning C++ - Introduction to c++ programming 1Learning C++ - Introduction to c++ programming 1
Learning C++ - Introduction to c++ programming 1Ali Aminian
 
Learn c++ Programming Language
Learn c++ Programming LanguageLearn c++ Programming Language
Learn c++ Programming LanguageSteve Johnson
 
Cs1123 3 c++ overview
Cs1123 3 c++ overviewCs1123 3 c++ overview
Cs1123 3 c++ overviewTAlha MAlik
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAAiman Hud
 
C++ programming program design including data structures
C++ programming program design including data structures C++ programming program design including data structures
C++ programming program design including data structures Ahmad Idrees
 
C Programming basics
C Programming basicsC Programming basics
C Programming basicsJitin Pillai
 
STRINGS IN C MRS.SOWMYA JYOTHI.pdf
STRINGS IN C MRS.SOWMYA JYOTHI.pdfSTRINGS IN C MRS.SOWMYA JYOTHI.pdf
STRINGS IN C MRS.SOWMYA JYOTHI.pdfSowmyaJyothi3
 
MANAGING INPUT AND OUTPUT OPERATIONS IN C MRS.SOWMYA JYOTHI.pdf
MANAGING INPUT AND OUTPUT OPERATIONS IN C    MRS.SOWMYA JYOTHI.pdfMANAGING INPUT AND OUTPUT OPERATIONS IN C    MRS.SOWMYA JYOTHI.pdf
MANAGING INPUT AND OUTPUT OPERATIONS IN C MRS.SOWMYA JYOTHI.pdfSowmyaJyothi3
 

What's hot (20)

basics of C and c++ by eteaching
basics of C and c++ by eteachingbasics of C and c++ by eteaching
basics of C and c++ by eteaching
 
Learning C++ - Introduction to c++ programming 1
Learning C++ - Introduction to c++ programming 1Learning C++ - Introduction to c++ programming 1
Learning C++ - Introduction to c++ programming 1
 
C++
C++C++
C++
 
c++
 c++  c++
c++
 
Learn c++ Programming Language
Learn c++ Programming LanguageLearn c++ Programming Language
Learn c++ Programming Language
 
Getting Started with C++
Getting Started with C++Getting Started with C++
Getting Started with C++
 
Basic concept of c++
Basic concept of c++Basic concept of c++
Basic concept of c++
 
Cs1123 3 c++ overview
Cs1123 3 c++ overviewCs1123 3 c++ overview
Cs1123 3 c++ overview
 
Session 5-exersice
Session 5-exersiceSession 5-exersice
Session 5-exersice
 
C++ Language
C++ LanguageC++ Language
C++ Language
 
Labsheet1stud
Labsheet1studLabsheet1stud
Labsheet1stud
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
 
Getting started with c++
Getting started with c++Getting started with c++
Getting started with c++
 
C++ programming program design including data structures
C++ programming program design including data structures C++ programming program design including data structures
C++ programming program design including data structures
 
Managing console input
Managing console inputManaging console input
Managing console input
 
C Programming basics
C Programming basicsC Programming basics
C Programming basics
 
C program
C programC program
C program
 
STRINGS IN C MRS.SOWMYA JYOTHI.pdf
STRINGS IN C MRS.SOWMYA JYOTHI.pdfSTRINGS IN C MRS.SOWMYA JYOTHI.pdf
STRINGS IN C MRS.SOWMYA JYOTHI.pdf
 
C Tokens
C TokensC Tokens
C Tokens
 
MANAGING INPUT AND OUTPUT OPERATIONS IN C MRS.SOWMYA JYOTHI.pdf
MANAGING INPUT AND OUTPUT OPERATIONS IN C    MRS.SOWMYA JYOTHI.pdfMANAGING INPUT AND OUTPUT OPERATIONS IN C    MRS.SOWMYA JYOTHI.pdf
MANAGING INPUT AND OUTPUT OPERATIONS IN C MRS.SOWMYA JYOTHI.pdf
 

Similar to Basics of C++ Programming Language Explained

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 IIBlue Elephant Consulting
 
Basics Of C++.pptx
Basics Of C++.pptxBasics Of C++.pptx
Basics Of C++.pptxDineshDhuri4
 
Chapter 2 - Structure of C++ Program
Chapter 2 - Structure of C++ ProgramChapter 2 - Structure of C++ Program
Chapter 2 - Structure of C++ ProgramDeepak Singh
 
C++ Programming Club-Lecture 1
C++ Programming Club-Lecture 1C++ Programming Club-Lecture 1
C++ Programming Club-Lecture 1Ammara Javed
 
C Programming- Harsh Sharma
C Programming- Harsh SharmaC Programming- Harsh Sharma
C Programming- Harsh SharmaHarsh Sharma
 
1.1 programming fundamentals
1.1 programming fundamentals1.1 programming fundamentals
1.1 programming fundamentalsJawad Khan
 
Ch2 C Fundamentals
Ch2 C FundamentalsCh2 C Fundamentals
Ch2 C FundamentalsSzeChingChen
 
Lecture 1.3 A Simple Program to Print a Line of Text.pdf
Lecture 1.3 A Simple Program to Print a Line of Text.pdfLecture 1.3 A Simple Program to Print a Line of Text.pdf
Lecture 1.3 A Simple Program to Print a Line of Text.pdfMianSaeedAkbar1
 
Practical basics on c++
Practical basics on c++Practical basics on c++
Practical basics on c++Marco Izzotti
 
Introduction to C++,Computer Science
Introduction to C++,Computer ScienceIntroduction to C++,Computer Science
Introduction to C++,Computer ScienceAbhinav Vishnoi
 

Similar to Basics of C++ Programming Language Explained (20)

Intro to c++
Intro to c++Intro to c++
Intro to c++
 
Common Programming Errors
Common Programming ErrorsCommon Programming Errors
Common Programming Errors
 
C Fundamental.docx
C Fundamental.docxC Fundamental.docx
C Fundamental.docx
 
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
 
Basics Of C++.pptx
Basics Of C++.pptxBasics Of C++.pptx
Basics Of C++.pptx
 
Fp201 unit2 1
Fp201 unit2 1Fp201 unit2 1
Fp201 unit2 1
 
Lecture 1
Lecture 1Lecture 1
Lecture 1
 
C++
C++C++
C++
 
Chapter 2 - Structure of C++ Program
Chapter 2 - Structure of C++ ProgramChapter 2 - Structure of C++ Program
Chapter 2 - Structure of C++ Program
 
Output
OutputOutput
Output
 
C++ Programming Club-Lecture 1
C++ Programming Club-Lecture 1C++ Programming Club-Lecture 1
C++ Programming Club-Lecture 1
 
C Programming- Harsh Sharma
C Programming- Harsh SharmaC Programming- Harsh Sharma
C Programming- Harsh Sharma
 
2621008 - C++ 1
2621008 -  C++ 12621008 -  C++ 1
2621008 - C++ 1
 
1.1 programming fundamentals
1.1 programming fundamentals1.1 programming fundamentals
1.1 programming fundamentals
 
Ch2 C Fundamentals
Ch2 C FundamentalsCh2 C Fundamentals
Ch2 C Fundamentals
 
Lecture 1.3 A Simple Program to Print a Line of Text.pdf
Lecture 1.3 A Simple Program to Print a Line of Text.pdfLecture 1.3 A Simple Program to Print a Line of Text.pdf
Lecture 1.3 A Simple Program to Print a Line of Text.pdf
 
Practical basics on c++
Practical basics on c++Practical basics on c++
Practical basics on c++
 
Introduction to C++,Computer Science
Introduction to C++,Computer ScienceIntroduction to C++,Computer Science
Introduction to C++,Computer Science
 
Intro cpp
Intro cppIntro cpp
Intro cpp
 

Recently uploaded

Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetHyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetEnjoy Anytime
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsHyundai Motor Group
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Hyundai Motor Group
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 

Recently uploaded (20)

Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetHyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 

Basics of C++ Programming Language Explained

  • 1. 1 1
  • 2. Khawaja Sharif Sediqi Basics of C++ Programming Language
  • 3. C++ • C++ is a general-purpose programing language. • C++ is used to create computer programs Anything from application , Music players and even video gamest. 3 i C++ was derived from C, and is largely based on it
  • 4. C++ is a: General purpose programing language Movie making program Client-side scripting language 4
  • 5. C++ is a: General purpose programing language Movie making program Client-side scripting language 5
  • 6. main Source code 1. // my first program in C++ 2. # include <iostream> 3. 4. int main () 5. { 6. std::cout<<“Hello Word!”; 7. } Output Hello Word! 6 Program execution begin with the main function ,Int main().
  • 7. main • Curly brackets { } indicate the beginning and end of function, which can also be called the function’s body. • The information inside the brackets indicates what the function does when executed. 7 i The entry point of every C++ program is main(), irrespective of what the program does.
  • 8. What is the starting point for a computer program? main function from <iostream> first line 8
  • 9. What is the starting point for a computer program? main function from <iostream> first line 9
  • 10. Your first C++ program 1. # include <iostream> 2. 3. int main () 4. { 5. std::cout<<“Hello Word!”; 6. } Hello Word! 10 The next line, Cout<<“Hello world !”; result in the display of “hello world “ to the screen.
  • 11. Your first C++ program • In C++ Stream are used to perform input and out put operations. • In the most program environments, the standard default output destination is the screen . • in C++ cout is the stream object used to access it. • Cout is used in combination with the insertion operator • Writ the insertion operator as << to insert the data that comes after it into the stream that comes before. 11 i In C++ , the semicolon is used to terminate a statement. Each statement must end with a semicolon . It indicate the end of one logical expression.
  • 12. Each instruction must end with a dot ( . ) Comma ( , ) Colon ( : ) Semicolon ( ; ) 12
  • 13. Each instruction must end with a dot ( . ) Comma ( , ) Colon ( : ) Semicolon ( ; ) 13
  • 14. Statement • A block is a set of logical connected statements, surrounded by opening and closing curly braces 1. { 2. cout<<“Hello Word!”; return 0; 3. } 14 i You can have multiple statement on a single line, as long as you remember to end each statement with a semicolon . Failing to do so will result in an error
  • 15. Components of a C++ program You can add multiple insertion operation after cout 1. { 2. cout<<“This” << “awesome!”; return 0; 3. } 15
  • 16. New Line The cout operator does not insert a line break at the end of the output. Own a way to print two line is to use the endl manipulator , which will put a line break 1. { 2. cout<<“Hello” << endl ; 3.cout<< “My name is Ahmad!”; return 0; 4. } 16
  • 17. What should be used to move to an new line start #include endl next line 17
  • 18. New Lines The new line character n can be used as an alternative to endl. The backslash () is called an escape character and indicate a “special” character. 1. { 2. cout<<“welcome n” ; 3.cout<< “My name is Ahmad!”; return 0; 4. } 18
  • 19. What is symbol for moving to a new line( alternative to the endl) a n b 19
  • 20. What is symbol for moving to a new line( alternative to the endl) a n b 20
  • 21. Comments Comments are explanatory statement that you can include in the C++ code to explain what the code is doing. The compiler ignores everything that appears int the comment.so none of that information shows in the result. A comment beginning with two slashes (//) is called single-line comment. The slashes tell the compiler to ignore everything that follows. until the end of the line 21
  • 22. Comment 1. # include <iostream> 2. using namespace std; 3. //std is declaration region 4. int main () 5. { 6. //pring “hello world” 7. cout<<“Hello Word!”; 8. return 0; 9. } Hello Word! 22 When the following code is compiled , it will ignore the // prints “ hello world” statement and will produce the following result.
  • 23. Which choice indicate a signal-line comment // single line comment ** single line comment ##single the comment 23
  • 24. Which choice indicate a signal-line comment // single line comment ** single line comment ##single the comment 24
  • 25. Multi-Line Comments Comment that require multiple lines begin with /* and end with */ You can place them on the same line or insert one or more lines between them. /* This is a comment */ /* C++ comments can Span multiple lines */ 25
  • 26. Create a block comment ( multiline comment) in C+ + This is a block /multiline Comment in C++ 26
  • 27. Create a block comment ( multiline comment) in C+ + This is a block /multiline Comment in C++ 27 /* */
  • 28. Which of the following in true Comments are ignored by the compiler Comments are used to confuse programmers single line comments starts with an * 28
  • 29. Which of the following in true Comments are ignored by the compiler Comments are used to confuse programmers single line comments starts with an * 29