SlideShare une entreprise Scribd logo
1  sur  22
Introduction to C++
BY HIMANSHU KAUSHIK
What is c++ ?
 C++ is a object-oriented language
 It is the “successor” to C, a procedural language
 (the “++” is called the successor operator in C++)
 C was derived from a language called B which was in turn derived from
BCPL
 C was developed in the 1970’s by Dennis Ritchie of AT&T Bell Labs
 C++ was developed in the early 1980’s by Bjarne Stroustrup of AT&T Bell
Labs.
 Most of C is a subset of C++
People & Programs
 User: an individual who runs, or executes,
a program
 Programmer: an individual who creates, or
writes, a program
C++ Programming
 Consists of…
Declarations
 Define the use of various identifiers, thus creating the elements used by the
program (computer)
Statements
 Or executable statements, representing actions the computer will take on
the user’s behalf
Identifiers
 Names for various entities used in a program;
used for...
 Variables: values that can change frequently
 Constants: values that never changes
 Functions: programming units that represents
complex operations
 Parameters: values that change infrequently
A Simple c++ Program
#include <iostream.h>
int main()
{
// Declarations
// Statements
return 0;
}
The Header File
#include <iostream.h>
int main()
{
// Declarations
// Statements
return 0;
}
 Compiler directive:
Tells the compiler
what to do before
compiling
 This one includes
source code from
another file
The Main Statement
#include <iostream.h>
int main()
{
// Declarations
// Statements
return 0;
}
 Header for main function
States…
 data type for the return
value
 identifier for function
 list of arguments between
parenthesis
(none for this function)
The Braces
#include <iostream.h>
int main()
{
// Declarations
// Statements
return 0;
}
Braces enclose the body of
the function
They represent the start and
end of the function
The Declaration Statement
#include <iostream.h>
int main()
{
// Declarations
// Statements
return 0;
}
 Declarations and
statements
 Main body of function
(or main part)
 “//” represents the start
of a comment
The return Statement
#include <iostream.h>
int main()
{
// Declarations
// Statements
return 0;
}
 Return statement
 specifies the value
the function returns
 All (almost)
declarations and
statements end with
a semi-colon “;”
Sample C++ Program
#include <iostream.h>
void main()
{
int number;
cout << “Enter a number” << endl;
cin >> number;
cout << “You entered: “ << number << endl;
}
What is the Output of this Program?
The DataTypes
#include <iostream.h>
void main()
{
int number;
cout << “Enter a number” << endl;
cin >> number;
cout << “You entered: “ << number << endl;
}
 Variable declaration
 The identifier number is
declared as being of
data type int, or integer
The Count ?
#include <iostream.h>
void main()
{
int number;
cout << “Enter a number” << endl;
cin >> number;
cout << “You entered: “ << number << endl;
}
 cout
the output statement for C++
 Note the direction of “<<“
 endl represents an end-of-line
Cin ?
#include <iostream.h>
void main()
{
int number;
cout << “Enter a number” << endl;
cin >> number;
cout << “You entered: “ << number << endl;
}
cin
the input statement for C++
Note the direction of “>>”
Copy That Down
#include <iostream.h>
void main()
{
int number;
cout << “Enter a number” << endl;
cin >> number;
cout << “You entered: “ << number << endl;
}
Value Assignment In c++
 Assignment is an operation that assigns
the value of an expression to a variable
 Ex. Total = 2 + 3 + 5
 First, the expresssion “2 + 3 + 5” is
evaluated
 Then, this value is assigned to the variable
“Total”
Assignment
 When a variable is declared, space is
allocated in the computer’s memory for
the variable
 Each data type requires a different
number of bytes in memory for storing a
variable
 int - 2
float - 4
double - 8
char, bool - 1
Arithmetic Operations
Addition: 2 + 3
Subtraction: 5 - 2
Multiplication: 10 * 4
Division: 12 / 3
I Have A problem for you
Problem: To determine the average of three
numbers
Task: Request, from the user, three numbers,
compute the average and the three numbers,
and print out the original values and the
computed average
Do it!
You have 20 minutes!
Any Queries ?

Contenu connexe

Tendances

Tendances (20)

C++ presentation
C++ presentationC++ presentation
C++ presentation
 
C++ language basic
C++ language basicC++ language basic
C++ language basic
 
C++ ppt
C++ pptC++ ppt
C++ ppt
 
Advanced Programming C++
Advanced Programming C++Advanced Programming C++
Advanced Programming C++
 
Introduction to c programming
Introduction to c programmingIntroduction to c programming
Introduction to c programming
 
C presentation
C presentationC presentation
C presentation
 
C fundamental
C fundamentalC fundamental
C fundamental
 
C++ Programming Language
C++ Programming Language C++ Programming Language
C++ Programming Language
 
Basics of C programming
Basics of C programmingBasics of C programming
Basics of C programming
 
C++ Language
C++ LanguageC++ Language
C++ Language
 
Data Type in C Programming
Data Type in C ProgrammingData Type in C Programming
Data Type in C Programming
 
Operators in C++
Operators in C++Operators in C++
Operators in C++
 
Operators and expressions in C++
Operators and expressions in C++Operators and expressions in C++
Operators and expressions in C++
 
C++ programming
C++ programmingC++ programming
C++ programming
 
History of c++
History of c++ History of c++
History of c++
 
data types in C programming
data types in C programmingdata types in C programming
data types in C programming
 
Introduction to cpp
Introduction to cppIntroduction to cpp
Introduction to cpp
 
Complete C++ programming Language Course
Complete C++ programming Language CourseComplete C++ programming Language Course
Complete C++ programming Language Course
 
FUNCTIONS IN c++ PPT
FUNCTIONS IN c++ PPTFUNCTIONS IN c++ PPT
FUNCTIONS IN c++ PPT
 
Data types in C
Data types in CData types in C
Data types in C
 

Similaire à Introduction to c++

C++ Overview
C++ OverviewC++ Overview
C++ Overview
kelleyc3
 

Similaire à Introduction to c++ (20)

C++
C++C++
C++
 
C++ functions
C++ functionsC++ functions
C++ functions
 
C++ functions
C++ functionsC++ functions
C++ functions
 
Introduction to c++
Introduction to c++Introduction to c++
Introduction to c++
 
Programming using c++ tool
Programming using c++ toolProgramming using c++ tool
Programming using c++ tool
 
Presentation on C language By Kirtika thakur
Presentation on C language By Kirtika thakurPresentation on C language By Kirtika thakur
Presentation on C language By Kirtika thakur
 
cpp-streams.ppt,C++ is the top choice of many programmers for creating powerf...
cpp-streams.ppt,C++ is the top choice of many programmers for creating powerf...cpp-streams.ppt,C++ is the top choice of many programmers for creating powerf...
cpp-streams.ppt,C++ is the top choice of many programmers for creating powerf...
 
C++ AND CATEGORIES OF SOFTWARE
C++ AND CATEGORIES OF SOFTWAREC++ AND CATEGORIES OF SOFTWARE
C++ AND CATEGORIES OF SOFTWARE
 
OOPS using C++
OOPS using C++OOPS using C++
OOPS using C++
 
C++basics
C++basicsC++basics
C++basics
 
7512635.ppt
7512635.ppt7512635.ppt
7512635.ppt
 
Chapter2
Chapter2Chapter2
Chapter2
 
unit_2 (1).pptx
unit_2 (1).pptxunit_2 (1).pptx
unit_2 (1).pptx
 
C++ Overview
C++ OverviewC++ Overview
C++ Overview
 
(Lect. 2 & 3) Introduction to C.ppt
(Lect. 2 & 3) Introduction to C.ppt(Lect. 2 & 3) Introduction to C.ppt
(Lect. 2 & 3) Introduction to C.ppt
 
C++ Functions.ppt
C++ Functions.pptC++ Functions.ppt
C++ Functions.ppt
 
BASIC C++ PROGRAMMING
BASIC C++ PROGRAMMINGBASIC C++ PROGRAMMING
BASIC C++ PROGRAMMING
 
c++basics.ppt
c++basics.pptc++basics.ppt
c++basics.ppt
 
C++basics
C++basicsC++basics
C++basics
 
C++basics
C++basicsC++basics
C++basics
 

Dernier

+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 
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
 
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)

Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
 
LEVEL 5 - SESSION 1 2023 (1).pptx - PDF 123456
LEVEL 5   - SESSION 1 2023 (1).pptx - PDF 123456LEVEL 5   - SESSION 1 2023 (1).pptx - PDF 123456
LEVEL 5 - SESSION 1 2023 (1).pptx - PDF 123456
 
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 🔝✔️✔️
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
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
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
ManageIQ - Sprint 236 Review - Slide Deck
ManageIQ - Sprint 236 Review - Slide DeckManageIQ - Sprint 236 Review - Slide Deck
ManageIQ - Sprint 236 Review - Slide Deck
 
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
 
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 🔝✔️✔️
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
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
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verifiedSector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdf
 

Introduction to c++

  • 1. Introduction to C++ BY HIMANSHU KAUSHIK
  • 2. What is c++ ?  C++ is a object-oriented language  It is the “successor” to C, a procedural language  (the “++” is called the successor operator in C++)  C was derived from a language called B which was in turn derived from BCPL  C was developed in the 1970’s by Dennis Ritchie of AT&T Bell Labs  C++ was developed in the early 1980’s by Bjarne Stroustrup of AT&T Bell Labs.  Most of C is a subset of C++
  • 3. People & Programs  User: an individual who runs, or executes, a program  Programmer: an individual who creates, or writes, a program
  • 4. C++ Programming  Consists of… Declarations  Define the use of various identifiers, thus creating the elements used by the program (computer) Statements  Or executable statements, representing actions the computer will take on the user’s behalf
  • 5. Identifiers  Names for various entities used in a program; used for...  Variables: values that can change frequently  Constants: values that never changes  Functions: programming units that represents complex operations  Parameters: values that change infrequently
  • 6. A Simple c++ Program #include <iostream.h> int main() { // Declarations // Statements return 0; }
  • 7. The Header File #include <iostream.h> int main() { // Declarations // Statements return 0; }  Compiler directive: Tells the compiler what to do before compiling  This one includes source code from another file
  • 8. The Main Statement #include <iostream.h> int main() { // Declarations // Statements return 0; }  Header for main function States…  data type for the return value  identifier for function  list of arguments between parenthesis (none for this function)
  • 9. The Braces #include <iostream.h> int main() { // Declarations // Statements return 0; } Braces enclose the body of the function They represent the start and end of the function
  • 10. The Declaration Statement #include <iostream.h> int main() { // Declarations // Statements return 0; }  Declarations and statements  Main body of function (or main part)  “//” represents the start of a comment
  • 11. The return Statement #include <iostream.h> int main() { // Declarations // Statements return 0; }  Return statement  specifies the value the function returns  All (almost) declarations and statements end with a semi-colon “;”
  • 12. Sample C++ Program #include <iostream.h> void main() { int number; cout << “Enter a number” << endl; cin >> number; cout << “You entered: “ << number << endl; } What is the Output of this Program?
  • 13. The DataTypes #include <iostream.h> void main() { int number; cout << “Enter a number” << endl; cin >> number; cout << “You entered: “ << number << endl; }  Variable declaration  The identifier number is declared as being of data type int, or integer
  • 14.
  • 15. The Count ? #include <iostream.h> void main() { int number; cout << “Enter a number” << endl; cin >> number; cout << “You entered: “ << number << endl; }  cout the output statement for C++  Note the direction of “<<“  endl represents an end-of-line
  • 16. Cin ? #include <iostream.h> void main() { int number; cout << “Enter a number” << endl; cin >> number; cout << “You entered: “ << number << endl; } cin the input statement for C++ Note the direction of “>>”
  • 17. Copy That Down #include <iostream.h> void main() { int number; cout << “Enter a number” << endl; cin >> number; cout << “You entered: “ << number << endl; }
  • 18. Value Assignment In c++  Assignment is an operation that assigns the value of an expression to a variable  Ex. Total = 2 + 3 + 5  First, the expresssion “2 + 3 + 5” is evaluated  Then, this value is assigned to the variable “Total”
  • 19. Assignment  When a variable is declared, space is allocated in the computer’s memory for the variable  Each data type requires a different number of bytes in memory for storing a variable  int - 2 float - 4 double - 8 char, bool - 1
  • 20. Arithmetic Operations Addition: 2 + 3 Subtraction: 5 - 2 Multiplication: 10 * 4 Division: 12 / 3
  • 21. I Have A problem for you Problem: To determine the average of three numbers Task: Request, from the user, three numbers, compute the average and the three numbers, and print out the original values and the computed average Do it! You have 20 minutes!