SlideShare uma empresa Scribd logo
1 de 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 ?

Mais conteĂșdo relacionado

Mais procurados

Mais procurados (20)

Introduction Of C++
Introduction Of C++Introduction Of C++
Introduction Of C++
 
C++ Language
C++ LanguageC++ Language
C++ Language
 
Variables in C Programming
Variables in C ProgrammingVariables in C Programming
Variables in C Programming
 
C++ programming
C++ programmingC++ programming
C++ programming
 
Intro to c++
Intro to c++Intro to c++
Intro to c++
 
Introduction to c++ ppt
Introduction to c++ pptIntroduction to c++ ppt
Introduction to c++ ppt
 
Data types in C
Data types in CData types in C
Data types in C
 
CSharp Presentation
CSharp PresentationCSharp Presentation
CSharp Presentation
 
Control statements in c
Control statements in cControl statements in c
Control statements in c
 
Data Type in C Programming
Data Type in C ProgrammingData Type in C Programming
Data Type in C Programming
 
C presentation book
C presentation bookC presentation book
C presentation book
 
Scope rules : local and global variables
Scope rules : local and global variablesScope rules : local and global variables
Scope rules : local and global variables
 
C++ Overview PPT
C++ Overview PPTC++ Overview PPT
C++ Overview PPT
 
Functions in c
Functions in cFunctions in c
Functions in c
 
Function in C program
Function in C programFunction in C program
Function in C program
 
data types in C programming
data types in C programmingdata types in C programming
data types in C programming
 
Enums in c
Enums in cEnums in c
Enums in c
 
History of c
History of cHistory of c
History of c
 
Introduction to Basic C programming 01
Introduction to Basic C programming 01Introduction to Basic C programming 01
Introduction to Basic C programming 01
 
File in C language
File in C languageFile in C language
File in C language
 

Semelhante a Introduction to c++

Introduction to cpp
Introduction to cppIntroduction to cpp
Introduction to cppNilesh Dalvi
 
C++ functions
C++ functionsC++ functions
C++ functionsDawood Jutt
 
C++ functions
C++ functionsC++ functions
C++ functionsDawood 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++ toolAbdullah 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 thakurThakurkirtika
 
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
 
OOPS using C++
OOPS using C++OOPS using C++
OOPS using C++cpjcollege
 
C++basics
C++basicsC++basics
C++basicsamna izzat
 
Chapter2
Chapter2Chapter2
Chapter2Anees999
 
C++ Overview
C++ OverviewC++ Overview
C++ Overviewkelleyc3
 
(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.pptatulchaudhary821
 
C++ Functions.ppt
C++ Functions.pptC++ Functions.ppt
C++ Functions.pptWaheedAnwar20
 
BASIC C++ PROGRAMMING
BASIC C++ PROGRAMMINGBASIC C++ PROGRAMMING
BASIC C++ PROGRAMMINGgufranresearcher
 
c++basics.ppt
c++basics.pptc++basics.ppt
c++basics.pptTatyaTope4
 

Semelhante a 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
 
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
 

Último

%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...masabamasaba
 
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open SourceWSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open SourceWSO2
 
%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 kaalfonteinmasabamasaba
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park masabamasaba
 
%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 tembisamasabamasaba
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2
 
%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 midrandmasabamasaba
 
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...masabamasaba
 
WSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - KeynoteWSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - KeynoteWSO2
 
%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 tembisamasabamasaba
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024VictoriaMetrics
 
WSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security ProgramWSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security ProgramWSO2
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...SelfMade bd
 
tonesoftg
tonesoftgtonesoftg
tonesoftglanshi9
 
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2
 
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2
 
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...WSO2
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...masabamasaba
 
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...WSO2
 

Último (20)

Abortion Pill Prices Tembisa [(+27832195400*)] đŸ„ Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] đŸ„ Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] đŸ„ Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] đŸ„ Women's Abortion Clinic in T...
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
 
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open SourceWSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
 
%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
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
%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
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
 
%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
 
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
 
WSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - KeynoteWSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - Keynote
 
%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
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
 
WSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security ProgramWSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security Program
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
tonesoftg
tonesoftgtonesoftg
tonesoftg
 
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
 
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
 
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
 
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
 

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!