SlideShare a Scribd company logo
1 of 17
Beginning with C++
Nilesh Dalvi
Patkar college
nileshdalvi01@gmail.com
C++
 C++ is an object-oriented programming
language.
 C++ was developed by Bjarne Stroustrup at
AT&T Bell Laboratories in Murray Hill, New
Jersey, USA.
 C++ is an extension of C with a major addition of
the class construct feature.
 Since the class was a major addition to the
original C language Stroustrup called the new
language 'C with Classes'.
C++
 However later in 1983 the name was changed to
C++.
 The idea of C++ comes from the C increment
operator ++ thereby suggesting that C++ is an
incremented version of C
 C++ is a superset of C.
 The three most important facilities that C++
adds on to C are classes, function overloading,
and operator overloading.
Simple C++ Program
#include<iostream>
using namespace std;
int main()‫‏‬
{
cout<<"C++ is better than C";
return 0;
getch();
}
C++
 Above example contains only one fucntion,
main().
 Execution begins at main().
 Every C++ program must have a main().
Comments
 // - (Single Line comment)‫‏‬
 /*
*/ -( Multiline comment)‫‏‬
for(j=0;j<10;/* hello */ j++) //Multiline only allowed
{
}
C++ Output Operator
 The Statement:
 cout<<”C++ is better than C”;
 This causes the string in quotation marks to be
displayed on the screen.
 This statement introduces two new C++ features,
cout and <<.
 cout: Is a predefined object that represents the
standard output stream in C++.
 Here the standard output stream represents the
screen.
C++ Output Operator
 It is also possible to redirect the output to other
output devices.
 << : Is called the insertion or put to operator.
 It inserts the contents to the variable on its right to
the object on its left.
 It is important to note that we can still use the
printf() for displaying an output.
 You may recall that the operator << is the bit-wise
left-shift operator and it can still be used for this
purpose. (Operator Overloading)
C++ iostream File
 #include <iostream>
 This directive causes the preprocessor to add the
contents of the iostream file to the program.
 It contains declarations for the identifier cout and the
operator <<.
 The header file iostream should be included at the
beginning of all programs that use input/output
statements.
 The header files with .h extension are ”old style” files
which should be used with old compilers.
Return Type of main()
 In C++ main() returns an integer type value to the
operating system.
 Therefore every main() in C++ should end with a
return 0; statement otherwise a warning or an error
might occur.
 Since main() returns an integer type value, return
type for main() is explicitly specified as int.
 Note that the default return type for all functions in
C++ is int.
Average of Two numbers
#include<iostream>
int main()‫‏‬
{
float num1,num2,sum,avg;
cout<<”Enter number 1”;
cin>>num1;
cout<<”Enter number 2”;
cin>>num2;
Average of Two numbers
sum=num1+num2;
avg=sum/2;
cout<<”Sum =” <<sum <<”n”;
cout<<”Average =”<<avg <<”n”;
return 0;
}
C++ Input Operator
 cin>>num1;
 Is an input statement and causes the program to wait
for the user to type in a number.
 The number keyed in is placed in the variable num1.
 The operator >> is known as extraction or get from
operator.
 It extracts the value from the keyboard and assigns it
to the variable on its right
C++ Input Operator
 Cout<<” Sum =” <<sum <<”n”;
 First sends the string ”Sum =” to cout and then send
the value of sum. Finally it sends the newline
character so that the next output will be in the new
line.
 The multiple use of << in one statement is called
casading.
 Cin>>num1>>num2;
 The vlaues are assigned from left to right. 10 & 20
entered then num1=10 & num2=20
Structure of C++ Program
Include Files
Class declaration
Class functions definitions
Main function program
#include<iostream.h>
#include<conio.h>
class person
{
int roll;
int marks;
public :
void getdata(void)
{
cout<<“Roll No:";
cin>>roll;
cout<<“Marks";
cin>>marks;
}
void display(void)
{
cout<<"Roll
No"<<roll;
cout<<"Marks
"<<marks;
}
};
int main()
{
person per1;
per1.getdata();
per1.display();
getch();
return 0;
}

More Related Content

What's hot

Variables in C++, data types in c++
Variables in C++, data types in c++Variables in C++, data types in c++
Variables in C++, data types in c++Neeru Mittal
 
Basic Data Types in C++
Basic Data Types in C++ Basic Data Types in C++
Basic Data Types in C++ Hridoy Bepari
 
Pointers, virtual function and polymorphism
Pointers, virtual function and polymorphismPointers, virtual function and polymorphism
Pointers, virtual function and polymorphismlalithambiga kamaraj
 
classes and objects in C++
classes and objects in C++classes and objects in C++
classes and objects in C++HalaiHansaika
 
Conditional Statement in C Language
Conditional Statement in C LanguageConditional Statement in C Language
Conditional Statement in C LanguageShaina Arora
 
STRINGS IN C MRS.SOWMYA JYOTHI.pdf
STRINGS IN C MRS.SOWMYA JYOTHI.pdfSTRINGS IN C MRS.SOWMYA JYOTHI.pdf
STRINGS IN C MRS.SOWMYA JYOTHI.pdfSowmyaJyothi3
 
Class and object in C++
Class and object in C++Class and object in C++
Class and object in C++rprajat007
 
C++ Programming Language
C++ Programming Language C++ Programming Language
C++ Programming Language Mohamed Loey
 
Dynamic memory allocation
Dynamic memory allocationDynamic memory allocation
Dynamic memory allocationViji B
 
Expression and Operartor In C Programming
Expression and Operartor In C Programming Expression and Operartor In C Programming
Expression and Operartor In C Programming Kamal Acharya
 
Dynamic memory allocation in c
Dynamic memory allocation in cDynamic memory allocation in c
Dynamic memory allocation in clavanya marichamy
 

What's hot (20)

Variables in C++, data types in c++
Variables in C++, data types in c++Variables in C++, data types in c++
Variables in C++, data types in c++
 
Introduction to c++
Introduction to c++Introduction to c++
Introduction to c++
 
Basic Data Types in C++
Basic Data Types in C++ Basic Data Types in C++
Basic Data Types in C++
 
Python exception handling
Python   exception handlingPython   exception handling
Python exception handling
 
Operators in C++
Operators in C++Operators in C++
Operators in C++
 
Basics of c++
Basics of c++Basics of c++
Basics of c++
 
Intro to c++
Intro to c++Intro to c++
Intro to c++
 
Pointers, virtual function and polymorphism
Pointers, virtual function and polymorphismPointers, virtual function and polymorphism
Pointers, virtual function and polymorphism
 
classes and objects in C++
classes and objects in C++classes and objects in C++
classes and objects in C++
 
Conditional Statement in C Language
Conditional Statement in C LanguageConditional Statement in C Language
Conditional Statement in C Language
 
Strings in c++
Strings in c++Strings in c++
Strings in c++
 
STRINGS IN C MRS.SOWMYA JYOTHI.pdf
STRINGS IN C MRS.SOWMYA JYOTHI.pdfSTRINGS IN C MRS.SOWMYA JYOTHI.pdf
STRINGS IN C MRS.SOWMYA JYOTHI.pdf
 
Class and object in C++
Class and object in C++Class and object in C++
Class and object in C++
 
Functions in c++
Functions in c++Functions in c++
Functions in c++
 
C++ Programming Language
C++ Programming Language C++ Programming Language
C++ Programming Language
 
Dynamic memory allocation
Dynamic memory allocationDynamic memory allocation
Dynamic memory allocation
 
Expression and Operartor In C Programming
Expression and Operartor In C Programming Expression and Operartor In C Programming
Expression and Operartor In C Programming
 
C++ Language
C++ LanguageC++ Language
C++ Language
 
Functions in C++
Functions in C++Functions in C++
Functions in C++
 
Dynamic memory allocation in c
Dynamic memory allocation in cDynamic memory allocation in c
Dynamic memory allocation in c
 

Viewers also liked

Inheritance : Extending Classes
Inheritance : Extending ClassesInheritance : Extending Classes
Inheritance : Extending ClassesNilesh Dalvi
 
2CPP08 - Overloading and Overriding
2CPP08 - Overloading and Overriding2CPP08 - Overloading and Overriding
2CPP08 - Overloading and OverridingMichael Heron
 
Introduction to oops concepts
Introduction to oops conceptsIntroduction to oops concepts
Introduction to oops conceptsNilesh Dalvi
 
Constructors and destructors
Constructors and destructorsConstructors and destructors
Constructors and destructorsNilesh Dalvi
 
Concept Of C++ Data Types
Concept Of C++ Data TypesConcept Of C++ Data Types
Concept Of C++ Data Typesk v
 
Function overloading and overriding
Function overloading and overridingFunction overloading and overriding
Function overloading and overridingRajab Ali
 
Function overloading in c++
Function overloading in c++Function overloading in c++
Function overloading in c++Learn By Watch
 
Operator overloading
Operator overloadingOperator overloading
Operator overloadingKumar
 
Presentation on overloading
Presentation on overloading Presentation on overloading
Presentation on overloading Charndeep Sekhon
 
Data Types and Variables In C Programming
Data Types and Variables In C ProgrammingData Types and Variables In C Programming
Data Types and Variables In C ProgrammingKamal Acharya
 

Viewers also liked (17)

14. Linked List
14. Linked List14. Linked List
14. Linked List
 
Inheritance : Extending Classes
Inheritance : Extending ClassesInheritance : Extending Classes
Inheritance : Extending Classes
 
3 Function Overloading
3 Function Overloading3 Function Overloading
3 Function Overloading
 
2CPP08 - Overloading and Overriding
2CPP08 - Overloading and Overriding2CPP08 - Overloading and Overriding
2CPP08 - Overloading and Overriding
 
Introduction to oops concepts
Introduction to oops conceptsIntroduction to oops concepts
Introduction to oops concepts
 
Data types
Data typesData types
Data types
 
Intro to C++ - language
Intro to C++ - languageIntro to C++ - language
Intro to C++ - language
 
Data types
Data typesData types
Data types
 
C++ programming
C++ programmingC++ programming
C++ programming
 
Constructors and destructors
Constructors and destructorsConstructors and destructors
Constructors and destructors
 
Concept Of C++ Data Types
Concept Of C++ Data TypesConcept Of C++ Data Types
Concept Of C++ Data Types
 
Function overloading and overriding
Function overloading and overridingFunction overloading and overriding
Function overloading and overriding
 
Function overloading in c++
Function overloading in c++Function overloading in c++
Function overloading in c++
 
Operator overloading
Operator overloadingOperator overloading
Operator overloading
 
Presentation on overloading
Presentation on overloading Presentation on overloading
Presentation on overloading
 
Function overloading
Function overloadingFunction overloading
Function overloading
 
Data Types and Variables In C Programming
Data Types and Variables In C ProgrammingData Types and Variables In C Programming
Data Types and Variables In C Programming
 

Similar to Introduction to cpp

C++ Overview
C++ OverviewC++ Overview
C++ Overviewkelleyc3
 
OOPS using C++
OOPS using C++OOPS using C++
OOPS using C++cpjcollege
 
basics of C and c++ by eteaching
basics of C and c++ by eteachingbasics of C and c++ by eteaching
basics of C and c++ by eteachingeteaching
 
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 itPushkarNiroula1
 
Practical basics on c++
Practical basics on c++Practical basics on c++
Practical basics on c++Marco Izzotti
 
introductiontoc-140704113737-phpapp01.pdf
introductiontoc-140704113737-phpapp01.pdfintroductiontoc-140704113737-phpapp01.pdf
introductiontoc-140704113737-phpapp01.pdfSameerKhanPathan7
 
Basics Of C++.pptx
Basics Of C++.pptxBasics Of C++.pptx
Basics Of C++.pptxDineshDhuri4
 
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
 
Unit 1 of c++ first program
Unit 1 of c++ first programUnit 1 of c++ first program
Unit 1 of c++ first programAKR Education
 
Programming using c++ tool
Programming using c++ toolProgramming using c++ tool
Programming using c++ toolAbdullah Jan
 
Basic c programming and explanation PPT1
Basic c programming and explanation PPT1Basic c programming and explanation PPT1
Basic c programming and explanation PPT1Rumman Ansari
 
Programming Fundamentals lecture 5
Programming Fundamentals lecture 5Programming Fundamentals lecture 5
Programming Fundamentals lecture 5REHAN IJAZ
 
Programming For Engineers Functions - Part #1.pptx
Programming For Engineers Functions - Part #1.pptxProgramming For Engineers Functions - Part #1.pptx
Programming For Engineers Functions - Part #1.pptxNoorAntakia
 
Chapter 2 - Structure of C++ Program
Chapter 2 - Structure of C++ ProgramChapter 2 - Structure of C++ Program
Chapter 2 - Structure of C++ ProgramDeepak Singh
 

Similar to Introduction to cpp (20)

C++ Overview
C++ OverviewC++ Overview
C++ Overview
 
Chapter2
Chapter2Chapter2
Chapter2
 
OOPS using C++
OOPS using C++OOPS using C++
OOPS using C++
 
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 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
 
Fp201 unit2 1
Fp201 unit2 1Fp201 unit2 1
Fp201 unit2 1
 
Practical basics on c++
Practical basics on c++Practical basics on c++
Practical basics on c++
 
introductiontoc-140704113737-phpapp01.pdf
introductiontoc-140704113737-phpapp01.pdfintroductiontoc-140704113737-phpapp01.pdf
introductiontoc-140704113737-phpapp01.pdf
 
Basics Of C++.pptx
Basics Of C++.pptxBasics Of C++.pptx
Basics Of C++.pptx
 
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...
 
Lecture 1
Lecture 1Lecture 1
Lecture 1
 
C++ AND CATEGORIES OF SOFTWARE
C++ AND CATEGORIES OF SOFTWAREC++ AND CATEGORIES OF SOFTWARE
C++ AND CATEGORIES OF SOFTWARE
 
Unit 1 of c++ first program
Unit 1 of c++ first programUnit 1 of c++ first program
Unit 1 of c++ first program
 
Programming using c++ tool
Programming using c++ toolProgramming using c++ tool
Programming using c++ tool
 
CP 04.pptx
CP 04.pptxCP 04.pptx
CP 04.pptx
 
Basic c programming and explanation PPT1
Basic c programming and explanation PPT1Basic c programming and explanation PPT1
Basic c programming and explanation PPT1
 
Programming Fundamentals lecture 5
Programming Fundamentals lecture 5Programming Fundamentals lecture 5
Programming Fundamentals lecture 5
 
Programming For Engineers Functions - Part #1.pptx
Programming For Engineers Functions - Part #1.pptxProgramming For Engineers Functions - Part #1.pptx
Programming For Engineers Functions - Part #1.pptx
 
basic program
basic programbasic program
basic program
 
Chapter 2 - Structure of C++ Program
Chapter 2 - Structure of C++ ProgramChapter 2 - Structure of C++ Program
Chapter 2 - Structure of C++ Program
 

More from Nilesh Dalvi

10. Introduction to Datastructure
10. Introduction to Datastructure10. Introduction to Datastructure
10. Introduction to DatastructureNilesh Dalvi
 
9. Input Output in java
9. Input Output in java9. Input Output in java
9. Input Output in javaNilesh Dalvi
 
6. Exception Handling
6. Exception Handling6. Exception Handling
6. Exception HandlingNilesh Dalvi
 
5. Inheritances, Packages and Intefaces
5. Inheritances, Packages and Intefaces5. Inheritances, Packages and Intefaces
5. Inheritances, Packages and IntefacesNilesh Dalvi
 
4. Classes and Methods
4. Classes and Methods4. Classes and Methods
4. Classes and MethodsNilesh Dalvi
 
3. Data types and Variables
3. Data types and Variables3. Data types and Variables
3. Data types and VariablesNilesh Dalvi
 
1. Overview of Java
1. Overview of Java1. Overview of Java
1. Overview of JavaNilesh Dalvi
 
Standard Template Library
Standard Template LibraryStandard Template Library
Standard Template LibraryNilesh Dalvi
 
Input and output in C++
Input and output in C++Input and output in C++
Input and output in C++Nilesh Dalvi
 
Operator Overloading
Operator OverloadingOperator Overloading
Operator OverloadingNilesh Dalvi
 

More from Nilesh Dalvi (20)

13. Queue
13. Queue13. Queue
13. Queue
 
12. Stack
12. Stack12. Stack
12. Stack
 
11. Arrays
11. Arrays11. Arrays
11. Arrays
 
10. Introduction to Datastructure
10. Introduction to Datastructure10. Introduction to Datastructure
10. Introduction to Datastructure
 
9. Input Output in java
9. Input Output in java9. Input Output in java
9. Input Output in java
 
8. String
8. String8. String
8. String
 
7. Multithreading
7. Multithreading7. Multithreading
7. Multithreading
 
6. Exception Handling
6. Exception Handling6. Exception Handling
6. Exception Handling
 
5. Inheritances, Packages and Intefaces
5. Inheritances, Packages and Intefaces5. Inheritances, Packages and Intefaces
5. Inheritances, Packages and Intefaces
 
4. Classes and Methods
4. Classes and Methods4. Classes and Methods
4. Classes and Methods
 
3. Data types and Variables
3. Data types and Variables3. Data types and Variables
3. Data types and Variables
 
2. Basics of Java
2. Basics of Java2. Basics of Java
2. Basics of Java
 
1. Overview of Java
1. Overview of Java1. Overview of Java
1. Overview of Java
 
Standard Template Library
Standard Template LibraryStandard Template Library
Standard Template Library
 
Templates
TemplatesTemplates
Templates
 
File handling
File handlingFile handling
File handling
 
Input and output in C++
Input and output in C++Input and output in C++
Input and output in C++
 
Strings
StringsStrings
Strings
 
Polymorphism
PolymorphismPolymorphism
Polymorphism
 
Operator Overloading
Operator OverloadingOperator Overloading
Operator Overloading
 

Recently uploaded

Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppCeline George
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfUmakantAnnand
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfakmcokerachita
 

Recently uploaded (20)

Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.Compdf
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdf
 

Introduction to cpp

  • 1. Beginning with C++ Nilesh Dalvi Patkar college nileshdalvi01@gmail.com
  • 2. C++  C++ is an object-oriented programming language.  C++ was developed by Bjarne Stroustrup at AT&T Bell Laboratories in Murray Hill, New Jersey, USA.  C++ is an extension of C with a major addition of the class construct feature.  Since the class was a major addition to the original C language Stroustrup called the new language 'C with Classes'.
  • 3. C++  However later in 1983 the name was changed to C++.  The idea of C++ comes from the C increment operator ++ thereby suggesting that C++ is an incremented version of C  C++ is a superset of C.  The three most important facilities that C++ adds on to C are classes, function overloading, and operator overloading.
  • 4. Simple C++ Program #include<iostream> using namespace std; int main()‫‏‬ { cout<<"C++ is better than C"; return 0; getch(); }
  • 5. C++  Above example contains only one fucntion, main().  Execution begins at main().  Every C++ program must have a main().
  • 6. Comments  // - (Single Line comment)‫‏‬  /* */ -( Multiline comment)‫‏‬ for(j=0;j<10;/* hello */ j++) //Multiline only allowed { }
  • 7. C++ Output Operator  The Statement:  cout<<”C++ is better than C”;  This causes the string in quotation marks to be displayed on the screen.  This statement introduces two new C++ features, cout and <<.  cout: Is a predefined object that represents the standard output stream in C++.  Here the standard output stream represents the screen.
  • 8. C++ Output Operator  It is also possible to redirect the output to other output devices.  << : Is called the insertion or put to operator.  It inserts the contents to the variable on its right to the object on its left.  It is important to note that we can still use the printf() for displaying an output.  You may recall that the operator << is the bit-wise left-shift operator and it can still be used for this purpose. (Operator Overloading)
  • 9. C++ iostream File  #include <iostream>  This directive causes the preprocessor to add the contents of the iostream file to the program.  It contains declarations for the identifier cout and the operator <<.  The header file iostream should be included at the beginning of all programs that use input/output statements.  The header files with .h extension are ”old style” files which should be used with old compilers.
  • 10. Return Type of main()  In C++ main() returns an integer type value to the operating system.  Therefore every main() in C++ should end with a return 0; statement otherwise a warning or an error might occur.  Since main() returns an integer type value, return type for main() is explicitly specified as int.  Note that the default return type for all functions in C++ is int.
  • 11. Average of Two numbers #include<iostream> int main()‫‏‬ { float num1,num2,sum,avg; cout<<”Enter number 1”; cin>>num1; cout<<”Enter number 2”; cin>>num2;
  • 12. Average of Two numbers sum=num1+num2; avg=sum/2; cout<<”Sum =” <<sum <<”n”; cout<<”Average =”<<avg <<”n”; return 0; }
  • 13. C++ Input Operator  cin>>num1;  Is an input statement and causes the program to wait for the user to type in a number.  The number keyed in is placed in the variable num1.  The operator >> is known as extraction or get from operator.  It extracts the value from the keyboard and assigns it to the variable on its right
  • 14. C++ Input Operator  Cout<<” Sum =” <<sum <<”n”;  First sends the string ”Sum =” to cout and then send the value of sum. Finally it sends the newline character so that the next output will be in the new line.  The multiple use of << in one statement is called casading.  Cin>>num1>>num2;  The vlaues are assigned from left to right. 10 & 20 entered then num1=10 & num2=20
  • 15. Structure of C++ Program Include Files Class declaration Class functions definitions Main function program
  • 16. #include<iostream.h> #include<conio.h> class person { int roll; int marks; public : void getdata(void) { cout<<“Roll No:"; cin>>roll; cout<<“Marks"; cin>>marks; }
  • 17. void display(void) { cout<<"Roll No"<<roll; cout<<"Marks "<<marks; } }; int main() { person per1; per1.getdata(); per1.display(); getch(); return 0; }