SlideShare une entreprise Scribd logo
1  sur  35
C++ Language Basic
By:
Engr MuhammadWaqarYounis
Todays Lecture
▪ Introduction
▪ Why programming?
▪ Programming Languages
▪ C++ as a programming Language
▪ First C++ Program
▪ Program Structure
▪ Semicolons and Blocks in C++
▪ Comments in C++
▪ Variable in C++
▪ Data type in C++
Why Programming?
▪ Here are two main reasons why one should learn programming. Most
Demanded Profession:These days technology is becoming so advance
with the help of computers. And for running such computers we need
software that is made using programming languages. It shows that
there are huge job opportunities in present and future.
▪ Our Civilization runs on Software:
• Most Engineering activities involves software
▪ Programming is important
• To interact with machines and computes
• To automate tasks
• To create intelligent machines, etc
Programming Languages
▪ Programmers write program in various programming languages,
some are directly understood by computers and other requiring
intermediate translation steps. Hundred of such languages are in
use today.These maybe divided into three general categories:
Machine language
Assembly language
High level language
• Procedural languages
• Object Oriented languages
Computer Program
▪ A computer program is a collection of instructions that
performs a specific task when executed by a computer.
▪ A computer program is usually written by a computer
programmer in a programming language.
▪ A collection of computer programs, libraries, and
related data are referred to as software.
C++ as a programming Language
▪ C++ is a sophisticated, efficient and a general-purpose
programming language based on C. It was developed by Bjarne
Stroustrup in 1979.
▪ Many of today’s operating systems, system drivers, browsers
and games use C++ as their core language.This makes C++ one
of the most popular languages today.
▪ Since it is an enhanced/extended version of C
programming language, C and C++ are often denoted together
as C/C++.
Features of C++
▪ C++ is fast: Since, C++ is an extended version of C, the C part of it is very low level.
This offers a huge boost in speed that high level languages like Python, Java don’t give
you.
▪ C++ is statically typed: In simple terms, C++ doesn’t allow the compiler to make
assumptions about the type of data e.g. 10 is different from “10” and you have to let C++
know which one you are talking about. This helps the compiler catch errors and bugs
before execution of the program.
▪ C++ is a multi-paradigm programming language: C++ supports at least 7 different
styles of programming and gives developers the freedom to choose one at their will.
▪ Object oriented programming with C++:Object oriented programming helps you solve
a complex problem intuitively. With its use in C++, you are able to divide these complex
problems into smaller sets by creating objects.
Uses of C++
▪ C++ is used by programmers to create computer software.
▪ It is used to create general systems software, drivers for various computer
devices, software for servers and software for specific applications and
also widely used in the creation of video games.
▪ C++ is used by many programmers of different types and coming from
different fields. C++ is mostly used to write device driver programs, system
software, and applications that depend on direct hardware manipulation
under real-time constraints.
▪ It is also used to teach the basics of object-oriented features because it is
simple and is also used in the fields of research.
▪ Many primary user interfaces and system files of Windows and Macintosh
are written using C++.
Major Application of C++
▪ Adobe Products like Photoshop, Illustrator, InDesign
▪ Amazon - one of the biggest e-commerce sites
▪ Autodesk products forComputerAided Design
▪ Facebook - social networking site are heavy C++ centric products.
▪ Browsers e.g Chrome
Moreover, the fact that there’s a huge community improving C++ on
every iteration means that it is only expected to be used even more in
the coming future.
BASIC STRUCTURE OF A C++ PROGRAM
#include<iostream.h>
#include<conio.h>
using namespace std;
void main()
{
clrscr();
**program code will be written here**
getch();
}
BASIC STRUCTURE OF A C++ PROGRAM
#include<iostream.h>
#is called Preprocessor directive
Preprocessing :
Preprocessing is the phase of compilation before the
actual execution.
BASIC STRUCTURE OF A C++ PROGRAM
#include<iostream.h>
#include<conio.h>
These are the header file inclusion statement.
Header Files:
Header files are the predefined files in the C++ library
using which we create new program.
BASIC STRUCTURE OF A C++ PROGRAM
iostream.h
Iostream stands for Input Output Stream
It contains functions related to input and
output. For ex.- cout,cin etc.
BASIC STRUCTURE OF A C++ PROGRAM
conio.h
conio stands for Console Input Output .
It contains functions related to Console screen input
and output.
>The output screen of C++ is called Console Screen.
BASIC STRUCTURE OF A C++ PROGRAM
using namespace std;
The statement is intuitive in itself, you are “using” the
“namespace” “std” in your file.
We use the namespace std to make it easier to reference
operations included in that namespace.
If we hadn’t used the namespace, we’d have written
std::cout instead of cout.
This tells the compiler that every cout is actually std::cout.
BASIC STRUCTURE OF A C++ PROGRAM
Semicolon ”;”
The semicolon is a terminal. It terminates a
statement.When missed or incorrectly
used, it will cause a lot of issues.
Ask any C++ programmer and they will tell
you at least one horror story related to the
semicolon ; .
BASIC STRUCTURE OF A C++ PROGRAM
voidmain()
This is the main() method/ function of a C++ program.
Actual execution of a program starts from main
method.
BASIC STRUCTURE OF A C++ PROGRAM
clrscr();
Function defined within conio.h file
It clears the previous output screen.
FIRST C++ PROGRAM
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
cout<<“My First C++ Program”;
getch();
}
TO COMPILE- Alt+F9
TO EXECUTE-Ctrl+F9
BASIC STRUCTURE OF A C++ PROGRAM
cout<<“ text to be display”;
Defined within iostream.h
The text written within double quotes(“ ”) will got displayed
on the output screen as it is.
BASIC STRUCTURE OF A C++ PROGRAM
getch();
Function defined within conio.h file
It holds the final output screen until any key is
pressed by user.
RULES OF C++ LANGUAGE
▪ Every program should have main()
▪ Every statement should be end with semicolon(;)
▪ This Language is case sensitive
▪ All the letter should be in lowercase.
Comments in a C++ Program
Comments are used to increase
understandability and readability of a program.
These comments will be ignored by the
compiler at the time of compilation/execution.
i.e, comments are part of a program but not the
part of compiled/executed code.
Type of Comments
SINGLE LINE COMMENT:
Starts with // and treats all the contents
following // as comments within that line
MULTIPLE LINE COMMENT:
Starts with /* and ends with */ and all the
contents in between will be treated as
comments
COMMENTS USAGE EXAMPLE
/*TITLE :- MY FIRST C++ PROGRAM
CREATED BY :- XYZ */
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr(); // to clear the output screen
cout<<“My First C++ Program”;
getch(); //to pause the final output
}
Variable in C++
▪ Variable are used in C++, where we need storage for any value, which will change in
program
▪ Variable can be declared in multiple ways each with different memory requirements
and functioning.
▪ Variable is the name of memory location allocated by the compiler depending upon
the datatype of the variable.
Datatypes and Modifiers in C++
Let's start with Datatypes.They are used to define
type of variables and contents used. Data types define
the way you use storage in the programs you write.
Data types can be of two types:
1. Built-in Datatypes
2. User-defined orAbstract Datatypes
Built-in Data Types
▪ These are the datatypes which are predefined and are wired directly
into the compiler. For e.g: int, char etc
Example:
Datatype Description
char for character storage (1 byte)
int for integral number (2 bytes)
float single precision floating point (4 bytes)
double double precision floating point numbers (8 bytes)
Declaration and Initialization
▪ Variable must be declared before they are used. Usually it is preferred to
declare them at the starting of the program, but in C++ they can be declared in
the middle of program too, but must be done before using them.
Scope of Variables
All the variables have their area of functioning, and out of that
boundary they don't hold their value, this boundary is called
scope of the variable.
For most of the cases its between the curly braces, in which
variable is declared that a variable exists, not outside it. We can
broadly divide variables into two main types:
▪ GlobalVariables
▪ Local variables
Global variables
▪ Global variables are those, which are once declared and can be used
throughout the lifetime of the program by any class or any function.
▪ They must be declared outside the main() function.
▪ If only declared, they can be assigned different values at different time in
program lifetime.
▪ Even if they are declared and initialized at the same time outside the
main() function, then also they can be assigned any value at any point in
the program.
They must be declared outside the main() function.
Global variables
Example:
Local Variables
▪ Local variables are the variables which exist only between the curly
braces, in which its declared.
▪ Outside that they are unavailable and leads to compile time error.
QUESTIONS?
THANK YOU

Contenu connexe

Tendances

Templates in C++
Templates in C++Templates in C++
Templates in C++
Tech_MX
 
Object Oriented Programming Concepts
Object Oriented Programming ConceptsObject Oriented Programming Concepts
Object Oriented Programming Concepts
thinkphp
 

Tendances (20)

C++ Overview PPT
C++ Overview PPTC++ Overview PPT
C++ Overview PPT
 
Class and object in C++
Class and object in C++Class and object in C++
Class and object in C++
 
Templates in C++
Templates in C++Templates in C++
Templates in C++
 
C introduction by thooyavan
C introduction by  thooyavanC introduction by  thooyavan
C introduction by thooyavan
 
functions of C++
functions of C++functions of C++
functions of C++
 
Functions in C++
Functions in C++Functions in C++
Functions in C++
 
Encapsulation C++
Encapsulation C++Encapsulation C++
Encapsulation C++
 
C by balaguruswami - e.balagurusamy
C   by balaguruswami - e.balagurusamyC   by balaguruswami - e.balagurusamy
C by balaguruswami - e.balagurusamy
 
OOPS Basics With Example
OOPS Basics With ExampleOOPS Basics With Example
OOPS Basics With Example
 
Operator overloading
Operator overloadingOperator overloading
Operator overloading
 
C++ programming
C++ programmingC++ programming
C++ programming
 
07. Virtual Functions
07. Virtual Functions07. Virtual Functions
07. Virtual Functions
 
Polymorphism in c++(ppt)
Polymorphism in c++(ppt)Polymorphism in c++(ppt)
Polymorphism in c++(ppt)
 
Object Oriented Programming Concepts
Object Oriented Programming ConceptsObject Oriented Programming Concepts
Object Oriented Programming Concepts
 
Data types in c++
Data types in c++Data types in c++
Data types in c++
 
Class and object in c++
Class and object in c++Class and object in c++
Class and object in c++
 
Tokens in C++
Tokens in C++Tokens in C++
Tokens in C++
 
friend function(c++)
friend function(c++)friend function(c++)
friend function(c++)
 
Introduction to c programming
Introduction to c programmingIntroduction to c programming
Introduction to c programming
 
Constructors in C++
Constructors in C++Constructors in C++
Constructors in C++
 

Similaire à C++ language basic

Learn C Programming Full Course Free
Learn C Programming Full Course FreeLearn C Programming Full Course Free
Learn C Programming Full Course Free
Dheeraj Patidar
 
C language introduction geeksfor geeks
C language introduction   geeksfor geeksC language introduction   geeksfor geeks
C language introduction geeksfor geeks
AashutoshChhedavi
 
Introduction-to-C-Part-1 JSAHSHAHSJAHSJAHSJHASJ
Introduction-to-C-Part-1 JSAHSHAHSJAHSJAHSJHASJIntroduction-to-C-Part-1 JSAHSHAHSJAHSJAHSJHASJ
Introduction-to-C-Part-1 JSAHSHAHSJAHSJAHSJHASJ
meharikiros2
 
Migrating From Cpp To C Sharp
Migrating From Cpp To C SharpMigrating From Cpp To C Sharp
Migrating From Cpp To C Sharp
Ganesh Samarthyam
 

Similaire à C++ language basic (20)

Session 1 - c++ intro
Session   1 - c++ introSession   1 - c++ intro
Session 1 - c++ intro
 
Learn C Programming Full Course Free
Learn C Programming Full Course FreeLearn C Programming Full Course Free
Learn C Programming Full Course Free
 
Unit 1 of c++ part 1 basic introduction
Unit 1 of c++ part 1 basic introductionUnit 1 of c++ part 1 basic introduction
Unit 1 of c++ part 1 basic introduction
 
Introduction-to-C-Part-1 (1).doc
Introduction-to-C-Part-1 (1).docIntroduction-to-C-Part-1 (1).doc
Introduction-to-C-Part-1 (1).doc
 
Object oriented programming 7 first steps in oop using c++
Object oriented programming 7 first steps in oop using  c++Object oriented programming 7 first steps in oop using  c++
Object oriented programming 7 first steps in oop using c++
 
Introduction to c language
Introduction to c language Introduction to c language
Introduction to c language
 
Introduction to C Programming
Introduction to C ProgrammingIntroduction to C Programming
Introduction to C Programming
 
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
 
Programming in c plus plus2
Programming in c plus plus2Programming in c plus plus2
Programming in c plus plus2
 
The basics of c programming
The basics of c programmingThe basics of c programming
The basics of c programming
 
C plus plus for hackers it security
C plus plus for hackers it securityC plus plus for hackers it security
C plus plus for hackers it security
 
C language
C languageC language
C language
 
Oops index
Oops indexOops index
Oops index
 
Learn C Language
Learn C LanguageLearn C Language
Learn C Language
 
C language introduction geeksfor geeks
C language introduction   geeksfor geeksC language introduction   geeksfor geeks
C language introduction geeksfor geeks
 
Introduction-to-C-Part-1.pptx
Introduction-to-C-Part-1.pptxIntroduction-to-C-Part-1.pptx
Introduction-to-C-Part-1.pptx
 
Introduction-to-C-Part-1 JSAHSHAHSJAHSJAHSJHASJ
Introduction-to-C-Part-1 JSAHSHAHSJAHSJAHSJHASJIntroduction-to-C-Part-1 JSAHSHAHSJAHSJAHSJHASJ
Introduction-to-C-Part-1 JSAHSHAHSJAHSJAHSJHASJ
 
Migrating From Cpp To C Sharp
Migrating From Cpp To C SharpMigrating From Cpp To C Sharp
Migrating From Cpp To C Sharp
 
Introduction-to-C-Part-1.pdf
Introduction-to-C-Part-1.pdfIntroduction-to-C-Part-1.pdf
Introduction-to-C-Part-1.pdf
 
C vs c++
C vs c++C vs c++
C vs c++
 

Dernier

introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
VishalKumarJha10
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
masabamasaba
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
mohitmore19
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
VictorSzoltysek
 

Dernier (20)

Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 

C++ language basic

  • 1. C++ Language Basic By: Engr MuhammadWaqarYounis
  • 2. Todays Lecture ▪ Introduction ▪ Why programming? ▪ Programming Languages ▪ C++ as a programming Language ▪ First C++ Program ▪ Program Structure ▪ Semicolons and Blocks in C++ ▪ Comments in C++ ▪ Variable in C++ ▪ Data type in C++
  • 3. Why Programming? ▪ Here are two main reasons why one should learn programming. Most Demanded Profession:These days technology is becoming so advance with the help of computers. And for running such computers we need software that is made using programming languages. It shows that there are huge job opportunities in present and future. ▪ Our Civilization runs on Software: • Most Engineering activities involves software ▪ Programming is important • To interact with machines and computes • To automate tasks • To create intelligent machines, etc
  • 4. Programming Languages ▪ Programmers write program in various programming languages, some are directly understood by computers and other requiring intermediate translation steps. Hundred of such languages are in use today.These maybe divided into three general categories: Machine language Assembly language High level language • Procedural languages • Object Oriented languages
  • 5. Computer Program ▪ A computer program is a collection of instructions that performs a specific task when executed by a computer. ▪ A computer program is usually written by a computer programmer in a programming language. ▪ A collection of computer programs, libraries, and related data are referred to as software.
  • 6. C++ as a programming Language ▪ C++ is a sophisticated, efficient and a general-purpose programming language based on C. It was developed by Bjarne Stroustrup in 1979. ▪ Many of today’s operating systems, system drivers, browsers and games use C++ as their core language.This makes C++ one of the most popular languages today. ▪ Since it is an enhanced/extended version of C programming language, C and C++ are often denoted together as C/C++.
  • 7. Features of C++ ▪ C++ is fast: Since, C++ is an extended version of C, the C part of it is very low level. This offers a huge boost in speed that high level languages like Python, Java don’t give you. ▪ C++ is statically typed: In simple terms, C++ doesn’t allow the compiler to make assumptions about the type of data e.g. 10 is different from “10” and you have to let C++ know which one you are talking about. This helps the compiler catch errors and bugs before execution of the program. ▪ C++ is a multi-paradigm programming language: C++ supports at least 7 different styles of programming and gives developers the freedom to choose one at their will. ▪ Object oriented programming with C++:Object oriented programming helps you solve a complex problem intuitively. With its use in C++, you are able to divide these complex problems into smaller sets by creating objects.
  • 8. Uses of C++ ▪ C++ is used by programmers to create computer software. ▪ It is used to create general systems software, drivers for various computer devices, software for servers and software for specific applications and also widely used in the creation of video games. ▪ C++ is used by many programmers of different types and coming from different fields. C++ is mostly used to write device driver programs, system software, and applications that depend on direct hardware manipulation under real-time constraints. ▪ It is also used to teach the basics of object-oriented features because it is simple and is also used in the fields of research. ▪ Many primary user interfaces and system files of Windows and Macintosh are written using C++.
  • 9. Major Application of C++ ▪ Adobe Products like Photoshop, Illustrator, InDesign ▪ Amazon - one of the biggest e-commerce sites ▪ Autodesk products forComputerAided Design ▪ Facebook - social networking site are heavy C++ centric products. ▪ Browsers e.g Chrome Moreover, the fact that there’s a huge community improving C++ on every iteration means that it is only expected to be used even more in the coming future.
  • 10. BASIC STRUCTURE OF A C++ PROGRAM #include<iostream.h> #include<conio.h> using namespace std; void main() { clrscr(); **program code will be written here** getch(); }
  • 11. BASIC STRUCTURE OF A C++ PROGRAM #include<iostream.h> #is called Preprocessor directive Preprocessing : Preprocessing is the phase of compilation before the actual execution.
  • 12. BASIC STRUCTURE OF A C++ PROGRAM #include<iostream.h> #include<conio.h> These are the header file inclusion statement. Header Files: Header files are the predefined files in the C++ library using which we create new program.
  • 13. BASIC STRUCTURE OF A C++ PROGRAM iostream.h Iostream stands for Input Output Stream It contains functions related to input and output. For ex.- cout,cin etc.
  • 14. BASIC STRUCTURE OF A C++ PROGRAM conio.h conio stands for Console Input Output . It contains functions related to Console screen input and output. >The output screen of C++ is called Console Screen.
  • 15. BASIC STRUCTURE OF A C++ PROGRAM using namespace std; The statement is intuitive in itself, you are “using” the “namespace” “std” in your file. We use the namespace std to make it easier to reference operations included in that namespace. If we hadn’t used the namespace, we’d have written std::cout instead of cout. This tells the compiler that every cout is actually std::cout.
  • 16. BASIC STRUCTURE OF A C++ PROGRAM Semicolon ”;” The semicolon is a terminal. It terminates a statement.When missed or incorrectly used, it will cause a lot of issues. Ask any C++ programmer and they will tell you at least one horror story related to the semicolon ; .
  • 17. BASIC STRUCTURE OF A C++ PROGRAM voidmain() This is the main() method/ function of a C++ program. Actual execution of a program starts from main method.
  • 18. BASIC STRUCTURE OF A C++ PROGRAM clrscr(); Function defined within conio.h file It clears the previous output screen.
  • 19. FIRST C++ PROGRAM #include<iostream.h> #include<conio.h> void main() { clrscr(); cout<<“My First C++ Program”; getch(); } TO COMPILE- Alt+F9 TO EXECUTE-Ctrl+F9
  • 20. BASIC STRUCTURE OF A C++ PROGRAM cout<<“ text to be display”; Defined within iostream.h The text written within double quotes(“ ”) will got displayed on the output screen as it is.
  • 21. BASIC STRUCTURE OF A C++ PROGRAM getch(); Function defined within conio.h file It holds the final output screen until any key is pressed by user.
  • 22. RULES OF C++ LANGUAGE ▪ Every program should have main() ▪ Every statement should be end with semicolon(;) ▪ This Language is case sensitive ▪ All the letter should be in lowercase.
  • 23. Comments in a C++ Program Comments are used to increase understandability and readability of a program. These comments will be ignored by the compiler at the time of compilation/execution. i.e, comments are part of a program but not the part of compiled/executed code.
  • 24. Type of Comments SINGLE LINE COMMENT: Starts with // and treats all the contents following // as comments within that line MULTIPLE LINE COMMENT: Starts with /* and ends with */ and all the contents in between will be treated as comments
  • 25. COMMENTS USAGE EXAMPLE /*TITLE :- MY FIRST C++ PROGRAM CREATED BY :- XYZ */ #include<iostream.h> #include<conio.h> void main() { clrscr(); // to clear the output screen cout<<“My First C++ Program”; getch(); //to pause the final output }
  • 26. Variable in C++ ▪ Variable are used in C++, where we need storage for any value, which will change in program ▪ Variable can be declared in multiple ways each with different memory requirements and functioning. ▪ Variable is the name of memory location allocated by the compiler depending upon the datatype of the variable.
  • 27. Datatypes and Modifiers in C++ Let's start with Datatypes.They are used to define type of variables and contents used. Data types define the way you use storage in the programs you write. Data types can be of two types: 1. Built-in Datatypes 2. User-defined orAbstract Datatypes
  • 28. Built-in Data Types ▪ These are the datatypes which are predefined and are wired directly into the compiler. For e.g: int, char etc Example: Datatype Description char for character storage (1 byte) int for integral number (2 bytes) float single precision floating point (4 bytes) double double precision floating point numbers (8 bytes)
  • 29. Declaration and Initialization ▪ Variable must be declared before they are used. Usually it is preferred to declare them at the starting of the program, but in C++ they can be declared in the middle of program too, but must be done before using them.
  • 30. Scope of Variables All the variables have their area of functioning, and out of that boundary they don't hold their value, this boundary is called scope of the variable. For most of the cases its between the curly braces, in which variable is declared that a variable exists, not outside it. We can broadly divide variables into two main types: ▪ GlobalVariables ▪ Local variables
  • 31. Global variables ▪ Global variables are those, which are once declared and can be used throughout the lifetime of the program by any class or any function. ▪ They must be declared outside the main() function. ▪ If only declared, they can be assigned different values at different time in program lifetime. ▪ Even if they are declared and initialized at the same time outside the main() function, then also they can be assigned any value at any point in the program. They must be declared outside the main() function.
  • 33. Local Variables ▪ Local variables are the variables which exist only between the curly braces, in which its declared. ▪ Outside that they are unavailable and leads to compile time error.