尊敬的 微信汇率:1円 ≈ 0.046166 元 支付宝汇率:1円 ≈ 0.046257元 [退出登录]
SlideShare a Scribd company logo
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 ?

More Related Content

What's hot

Features of c
Features of cFeatures of c
Features of c
Hitesh Kumar
 
Basics of C programming
Basics of C programmingBasics of C programming
Basics of C programming
avikdhupar
 
Introduction to programming
Introduction to programmingIntroduction to programming
Introduction to programming
Neeru Mittal
 
Introduction to c++ ppt
Introduction to c++ pptIntroduction to c++ ppt
Introduction to c++ ppt
Prof. Dr. K. Adisesha
 
Functions in python slide share
Functions in python slide shareFunctions in python slide share
Functions in python slide share
Devashish Kumar
 
Presentation on Programming Languages.
Presentation on Programming Languages.Presentation on Programming Languages.
Presentation on Programming Languages.
Mohammad Shakirul islam
 
Introduction of c programming
Introduction of c programmingIntroduction of c programming
Introduction of c programming
Tarun Sharma
 
Introduction to C++
Introduction to C++Introduction to C++
Introduction to C++
Sikder Tahsin Al-Amin
 
Notes of c programming 1st unit BCA I SEM
Notes of c programming  1st unit BCA I SEMNotes of c programming  1st unit BCA I SEM
Notes of c programming 1st unit BCA I SEM
Mansi Tyagi
 
Operator Overloading
Operator OverloadingOperator Overloading
Operator Overloading
Nilesh Dalvi
 
C++ Programming Language
C++ Programming Language C++ Programming Language
C++ Programming Language
Mohamed Loey
 
C if else
C if elseC if else
C if else
Ritwik Das
 
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
eteaching
 
INTRODUCTION TO C PROGRAMMING
INTRODUCTION TO C PROGRAMMINGINTRODUCTION TO C PROGRAMMING
INTRODUCTION TO C PROGRAMMING
Abhishek Dwivedi
 
Presentation on C++ Programming Language
Presentation on C++ Programming LanguagePresentation on C++ Programming Language
Presentation on C++ Programming Language
satvirsandhu9
 
C++ Overview PPT
C++ Overview PPTC++ Overview PPT
C++ Overview PPT
Thooyavan Venkatachalam
 
1. over view and history of c
1. over view and history of c1. over view and history of c
1. over view and history of c
Harish Kumawat
 
C programming
C programmingC programming
Object oriented programming c++
Object oriented programming c++Object oriented programming c++
Object oriented programming c++
Ankur Pandey
 
Virtual base class
Virtual base classVirtual base class
Virtual base class
Tech_MX
 

What's hot (20)

Features of c
Features of cFeatures of c
Features of c
 
Basics of C programming
Basics of C programmingBasics of C programming
Basics of C programming
 
Introduction to programming
Introduction to programmingIntroduction to programming
Introduction to programming
 
Introduction to c++ ppt
Introduction to c++ pptIntroduction to c++ ppt
Introduction to c++ ppt
 
Functions in python slide share
Functions in python slide shareFunctions in python slide share
Functions in python slide share
 
Presentation on Programming Languages.
Presentation on Programming Languages.Presentation on Programming Languages.
Presentation on Programming Languages.
 
Introduction of c programming
Introduction of c programmingIntroduction of c programming
Introduction of c programming
 
Introduction to C++
Introduction to C++Introduction to C++
Introduction to C++
 
Notes of c programming 1st unit BCA I SEM
Notes of c programming  1st unit BCA I SEMNotes of c programming  1st unit BCA I SEM
Notes of c programming 1st unit BCA I SEM
 
Operator Overloading
Operator OverloadingOperator Overloading
Operator Overloading
 
C++ Programming Language
C++ Programming Language C++ Programming Language
C++ Programming Language
 
C if else
C if elseC if else
C if else
 
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
 
INTRODUCTION TO C PROGRAMMING
INTRODUCTION TO C PROGRAMMINGINTRODUCTION TO C PROGRAMMING
INTRODUCTION TO C PROGRAMMING
 
Presentation on C++ Programming Language
Presentation on C++ Programming LanguagePresentation on C++ Programming Language
Presentation on C++ Programming Language
 
C++ Overview PPT
C++ Overview PPTC++ Overview PPT
C++ Overview PPT
 
1. over view and history of c
1. over view and history of c1. over view and history of c
1. over view and history of c
 
C programming
C programmingC programming
C programming
 
Object oriented programming c++
Object oriented programming c++Object oriented programming c++
Object oriented programming c++
 
Virtual base class
Virtual base classVirtual base class
Virtual base class
 

Similar to Introduction to c++

Introduction to cpp
Introduction to cppIntroduction to cpp
Introduction to cpp
Nilesh Dalvi
 
C++
C++C++
C++ functions
C++ functionsC++ functions
C++ functions
Dawood Jutt
 
C++ functions
C++ functionsC++ functions
C++ functions
Dawood Jutt
 
Introduction to c++
Introduction to c++Introduction to c++
Introduction to c++
somu rajesh
 
Programming using c++ tool
Programming using c++ toolProgramming using c++ tool
Programming using c++ tool
Abdullah Jan
 
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
Thakurkirtika
 
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...
bhargavi804095
 
C++ AND CATEGORIES OF SOFTWARE
C++ AND CATEGORIES OF SOFTWAREC++ AND CATEGORIES OF SOFTWARE
C++ AND CATEGORIES OF SOFTWARE
UNIVERSITY OF ENGINEERING AND TECHNOLOGY TAXILA
 
OOPS using C++
OOPS using C++OOPS using C++
C++basics
C++basicsC++basics
C++basics
amna izzat
 
7512635.ppt
7512635.ppt7512635.ppt
7512635.ppt
ssuserda85e6
 
Chapter2
Chapter2Chapter2
Chapter2
Anees999
 
unit_2 (1).pptx
unit_2 (1).pptxunit_2 (1).pptx
unit_2 (1).pptx
JVenkateshGoud
 
Fundamental of programming Fundamental of programming
Fundamental of programming Fundamental of programmingFundamental of programming Fundamental of programming
Fundamental of programming Fundamental of programming
LidetAdmassu
 
C++ Overview
C++ OverviewC++ Overview
C++ Overview
kelleyc3
 
(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
atulchaudhary821
 
C++ Functions.ppt
C++ Functions.pptC++ Functions.ppt
C++ Functions.ppt
WaheedAnwar20
 
BASIC C++ PROGRAMMING
BASIC C++ PROGRAMMINGBASIC C++ PROGRAMMING
BASIC C++ PROGRAMMING
gufranresearcher
 
Functions.pptx, programming language in c
Functions.pptx, programming language in cFunctions.pptx, programming language in c
Functions.pptx, programming language in c
floraaluoch3
 

Similar to Introduction to c++ (20)

Introduction to cpp
Introduction to cppIntroduction to cpp
Introduction to cpp
 
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
 
Fundamental of programming Fundamental of programming
Fundamental of programming Fundamental of programmingFundamental of programming Fundamental of programming
Fundamental of programming Fundamental of programming
 
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
 
Functions.pptx, programming language in c
Functions.pptx, programming language in cFunctions.pptx, programming language in c
Functions.pptx, programming language in c
 

Recently uploaded

What’s new in VictoriaMetrics - Q2 2024 Update
What’s new in VictoriaMetrics - Q2 2024 UpdateWhat’s new in VictoriaMetrics - Q2 2024 Update
What’s new in VictoriaMetrics - Q2 2024 Update
VictoriaMetrics
 
Top Call Girls Lucknow ✔ 9352988975 ✔ Hi I Am Divya Vip Call Girl Services Pr...
Top Call Girls Lucknow ✔ 9352988975 ✔ Hi I Am Divya Vip Call Girl Services Pr...Top Call Girls Lucknow ✔ 9352988975 ✔ Hi I Am Divya Vip Call Girl Services Pr...
Top Call Girls Lucknow ✔ 9352988975 ✔ Hi I Am Divya Vip Call Girl Services Pr...
simmi singh$A17
 
Digital Marketing Introduction and Conclusion
Digital Marketing Introduction and ConclusionDigital Marketing Introduction and Conclusion
Digital Marketing Introduction and Conclusion
Staff AgentAI
 
What’s New in VictoriaLogs - Q2 2024 Update
What’s New in VictoriaLogs - Q2 2024 UpdateWhat’s New in VictoriaLogs - Q2 2024 Update
What’s New in VictoriaLogs - Q2 2024 Update
VictoriaMetrics
 
SAP ECC & S4 HANA PPT COMPARISON MM.pptx
SAP ECC & S4 HANA PPT COMPARISON MM.pptxSAP ECC & S4 HANA PPT COMPARISON MM.pptx
SAP ECC & S4 HANA PPT COMPARISON MM.pptx
aneeshmanikantan2341
 
🔥 Kolkata Call Girls  👉 9079923931 👫 High Profile Call Girls Whatsapp Number ...
🔥 Kolkata Call Girls  👉 9079923931 👫 High Profile Call Girls Whatsapp Number ...🔥 Kolkata Call Girls  👉 9079923931 👫 High Profile Call Girls Whatsapp Number ...
🔥 Kolkata Call Girls  👉 9079923931 👫 High Profile Call Girls Whatsapp Number ...
tinakumariji156
 
The Ultimate Guide to Top 36 DevOps Testing Tools for 2024.pdf
The Ultimate Guide to Top 36 DevOps Testing Tools for 2024.pdfThe Ultimate Guide to Top 36 DevOps Testing Tools for 2024.pdf
The Ultimate Guide to Top 36 DevOps Testing Tools for 2024.pdf
kalichargn70th171
 
Building API data products on top of your real-time data infrastructure
Building API data products on top of your real-time data infrastructureBuilding API data products on top of your real-time data infrastructure
Building API data products on top of your real-time data infrastructure
confluent
 
Extreme DDD Modelling Patterns - 2024 Devoxx Poland
Extreme DDD Modelling Patterns - 2024 Devoxx PolandExtreme DDD Modelling Patterns - 2024 Devoxx Poland
Extreme DDD Modelling Patterns - 2024 Devoxx Poland
Alberto Brandolini
 
OpenChain Webinar - Open Source Due Diligence for M&A - 2024-06-17
OpenChain Webinar - Open Source Due Diligence for M&A - 2024-06-17OpenChain Webinar - Open Source Due Diligence for M&A - 2024-06-17
OpenChain Webinar - Open Source Due Diligence for M&A - 2024-06-17
Shane Coughlan
 
TheFutureIsDynamic-BoxLang-CFCamp2024.pdf
TheFutureIsDynamic-BoxLang-CFCamp2024.pdfTheFutureIsDynamic-BoxLang-CFCamp2024.pdf
TheFutureIsDynamic-BoxLang-CFCamp2024.pdf
Ortus Solutions, Corp
 
AI Based Testing - A Comprehensive Guide.pdf
AI Based Testing - A Comprehensive Guide.pdfAI Based Testing - A Comprehensive Guide.pdf
AI Based Testing - A Comprehensive Guide.pdf
kalichargn70th171
 
Premium Call Girls In Ahmedabad 💯Call Us 🔝 7426014248 🔝Independent Ahmedabad ...
Premium Call Girls In Ahmedabad 💯Call Us 🔝 7426014248 🔝Independent Ahmedabad ...Premium Call Girls In Ahmedabad 💯Call Us 🔝 7426014248 🔝Independent Ahmedabad ...
Premium Call Girls In Ahmedabad 💯Call Us 🔝 7426014248 🔝Independent Ahmedabad ...
Anita pandey
 
Accelerate your Sitecore development with GenAI
Accelerate your Sitecore development with GenAIAccelerate your Sitecore development with GenAI
Accelerate your Sitecore development with GenAI
Ahmed Okour
 
1 Million Orange Stickies later - Devoxx Poland 2024
1 Million Orange Stickies later - Devoxx Poland 20241 Million Orange Stickies later - Devoxx Poland 2024
1 Million Orange Stickies later - Devoxx Poland 2024
Alberto Brandolini
 
Call Girls Goa 💯Call Us 🔝 7426014248 🔝 Independent Goa Escorts Service Available
Call Girls Goa 💯Call Us 🔝 7426014248 🔝 Independent Goa Escorts Service AvailableCall Girls Goa 💯Call Us 🔝 7426014248 🔝 Independent Goa Escorts Service Available
Call Girls Goa 💯Call Us 🔝 7426014248 🔝 Independent Goa Escorts Service Available
sapnaanpad7
 
Photo Copier Xerox Machine annual maintenance contract system.pdf
Photo Copier Xerox Machine annual maintenance contract system.pdfPhoto Copier Xerox Machine annual maintenance contract system.pdf
Photo Copier Xerox Machine annual maintenance contract system.pdf
SERVE WELL CRM NASHIK
 
119321250-History-of-Computer-Programming.ppt
119321250-History-of-Computer-Programming.ppt119321250-History-of-Computer-Programming.ppt
119321250-History-of-Computer-Programming.ppt
lavesingh522
 
Trailhead Talks_ Journey of an All-Star Ranger .pptx
Trailhead Talks_ Journey of an All-Star Ranger .pptxTrailhead Talks_ Journey of an All-Star Ranger .pptx
Trailhead Talks_ Journey of an All-Star Ranger .pptx
ImtiazBinMohiuddin
 
Ensuring Efficiency and Speed with Practical Solutions for Clinical Operations
Ensuring Efficiency and Speed with Practical Solutions for Clinical OperationsEnsuring Efficiency and Speed with Practical Solutions for Clinical Operations
Ensuring Efficiency and Speed with Practical Solutions for Clinical Operations
OnePlan Solutions
 

Recently uploaded (20)

What’s new in VictoriaMetrics - Q2 2024 Update
What’s new in VictoriaMetrics - Q2 2024 UpdateWhat’s new in VictoriaMetrics - Q2 2024 Update
What’s new in VictoriaMetrics - Q2 2024 Update
 
Top Call Girls Lucknow ✔ 9352988975 ✔ Hi I Am Divya Vip Call Girl Services Pr...
Top Call Girls Lucknow ✔ 9352988975 ✔ Hi I Am Divya Vip Call Girl Services Pr...Top Call Girls Lucknow ✔ 9352988975 ✔ Hi I Am Divya Vip Call Girl Services Pr...
Top Call Girls Lucknow ✔ 9352988975 ✔ Hi I Am Divya Vip Call Girl Services Pr...
 
Digital Marketing Introduction and Conclusion
Digital Marketing Introduction and ConclusionDigital Marketing Introduction and Conclusion
Digital Marketing Introduction and Conclusion
 
What’s New in VictoriaLogs - Q2 2024 Update
What’s New in VictoriaLogs - Q2 2024 UpdateWhat’s New in VictoriaLogs - Q2 2024 Update
What’s New in VictoriaLogs - Q2 2024 Update
 
SAP ECC & S4 HANA PPT COMPARISON MM.pptx
SAP ECC & S4 HANA PPT COMPARISON MM.pptxSAP ECC & S4 HANA PPT COMPARISON MM.pptx
SAP ECC & S4 HANA PPT COMPARISON MM.pptx
 
🔥 Kolkata Call Girls  👉 9079923931 👫 High Profile Call Girls Whatsapp Number ...
🔥 Kolkata Call Girls  👉 9079923931 👫 High Profile Call Girls Whatsapp Number ...🔥 Kolkata Call Girls  👉 9079923931 👫 High Profile Call Girls Whatsapp Number ...
🔥 Kolkata Call Girls  👉 9079923931 👫 High Profile Call Girls Whatsapp Number ...
 
The Ultimate Guide to Top 36 DevOps Testing Tools for 2024.pdf
The Ultimate Guide to Top 36 DevOps Testing Tools for 2024.pdfThe Ultimate Guide to Top 36 DevOps Testing Tools for 2024.pdf
The Ultimate Guide to Top 36 DevOps Testing Tools for 2024.pdf
 
Building API data products on top of your real-time data infrastructure
Building API data products on top of your real-time data infrastructureBuilding API data products on top of your real-time data infrastructure
Building API data products on top of your real-time data infrastructure
 
Extreme DDD Modelling Patterns - 2024 Devoxx Poland
Extreme DDD Modelling Patterns - 2024 Devoxx PolandExtreme DDD Modelling Patterns - 2024 Devoxx Poland
Extreme DDD Modelling Patterns - 2024 Devoxx Poland
 
OpenChain Webinar - Open Source Due Diligence for M&A - 2024-06-17
OpenChain Webinar - Open Source Due Diligence for M&A - 2024-06-17OpenChain Webinar - Open Source Due Diligence for M&A - 2024-06-17
OpenChain Webinar - Open Source Due Diligence for M&A - 2024-06-17
 
TheFutureIsDynamic-BoxLang-CFCamp2024.pdf
TheFutureIsDynamic-BoxLang-CFCamp2024.pdfTheFutureIsDynamic-BoxLang-CFCamp2024.pdf
TheFutureIsDynamic-BoxLang-CFCamp2024.pdf
 
AI Based Testing - A Comprehensive Guide.pdf
AI Based Testing - A Comprehensive Guide.pdfAI Based Testing - A Comprehensive Guide.pdf
AI Based Testing - A Comprehensive Guide.pdf
 
Premium Call Girls In Ahmedabad 💯Call Us 🔝 7426014248 🔝Independent Ahmedabad ...
Premium Call Girls In Ahmedabad 💯Call Us 🔝 7426014248 🔝Independent Ahmedabad ...Premium Call Girls In Ahmedabad 💯Call Us 🔝 7426014248 🔝Independent Ahmedabad ...
Premium Call Girls In Ahmedabad 💯Call Us 🔝 7426014248 🔝Independent Ahmedabad ...
 
Accelerate your Sitecore development with GenAI
Accelerate your Sitecore development with GenAIAccelerate your Sitecore development with GenAI
Accelerate your Sitecore development with GenAI
 
1 Million Orange Stickies later - Devoxx Poland 2024
1 Million Orange Stickies later - Devoxx Poland 20241 Million Orange Stickies later - Devoxx Poland 2024
1 Million Orange Stickies later - Devoxx Poland 2024
 
Call Girls Goa 💯Call Us 🔝 7426014248 🔝 Independent Goa Escorts Service Available
Call Girls Goa 💯Call Us 🔝 7426014248 🔝 Independent Goa Escorts Service AvailableCall Girls Goa 💯Call Us 🔝 7426014248 🔝 Independent Goa Escorts Service Available
Call Girls Goa 💯Call Us 🔝 7426014248 🔝 Independent Goa Escorts Service Available
 
Photo Copier Xerox Machine annual maintenance contract system.pdf
Photo Copier Xerox Machine annual maintenance contract system.pdfPhoto Copier Xerox Machine annual maintenance contract system.pdf
Photo Copier Xerox Machine annual maintenance contract system.pdf
 
119321250-History-of-Computer-Programming.ppt
119321250-History-of-Computer-Programming.ppt119321250-History-of-Computer-Programming.ppt
119321250-History-of-Computer-Programming.ppt
 
Trailhead Talks_ Journey of an All-Star Ranger .pptx
Trailhead Talks_ Journey of an All-Star Ranger .pptxTrailhead Talks_ Journey of an All-Star Ranger .pptx
Trailhead Talks_ Journey of an All-Star Ranger .pptx
 
Ensuring Efficiency and Speed with Practical Solutions for Clinical Operations
Ensuring Efficiency and Speed with Practical Solutions for Clinical OperationsEnsuring Efficiency and Speed with Practical Solutions for Clinical Operations
Ensuring Efficiency and Speed with Practical Solutions for Clinical Operations
 

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!
  翻译: