SlideShare a Scribd company logo
1 of 31
Overview of C++ language
Lecture’s outline

 What is C++?
 Identifiers.
 Constant
 Semicolons & Blocks in C++
 Data type
 Comments
 Operator
 Declaration of variables
 Giving value to variable
 C++ statements

                prepared by Taif.A.S.G
What is C++?
• Developed by Bjarne Stroustrup (in 1979 at Bell Labs)
• C++ is regarded as a middle-level language, as it comprises a
  combination of both high-level and low-level language features.
• C++ is a statically typed, compiled, general purpose, case-
  sensitive, free-form programming language that supports
  procedural, object-oriented, and generic programming.
• C++ is a superset of C that enhancement to the C language and
  originally named C with Classes but later it was renamed C++.

                         prepared by Taif.A.S.G
identifiers
They are used for naming classes
function, module, variables, object in a program.
They follow the following rules:
1) They can have alphabets , digits, and the underscore(_).
2) They must not begin with a digit.
3) Uppercase and lowercase are distinct.
4) They can be of any length.
5) It should not be a keyword.
6) White space is not allowed.

                      prepared by Taif.A.S.G
Constant
Constant is one whose value cannot be changed after it has
been initialized-any attempt to assign to field will produce a
compile-error .So, we can declare the constant by using
const field and use all uppercase letter.
Syntax of declare the constant is:
  const type name=value

Example:

const int STRENGTH = 100;
const float PI = 3.14;
                         prepared by Taif.A.S.G
Semicolons & Blocks in C++:
• In C++, the semicolon is a statement terminator.
  That is, each individual statement must be ended
  with a semicolon. It indicates the end of one logical
  entity.
• For example: following are two different
  statements:
  x = y;
  y = y+1;


                       prepared by Taif.A.S.G             6
Data type




prepared by Taif.A.S.G
Comments
C++ can use both the single line comments and multi-line
comments .
single line comments begin with // and end at the end of line.
For longer comments we can create multi-line comments by
starting with /* and ending with */




                        prepared by Taif.A.S.G
Operator
* / % + - are the mathematical operators
* / % have a higher precedence than + or –           mathematical
                                                     operators
 ++ Increment operator         –– Decrement operator
 ==    Equal (careful)
 !=            Not equal
 >=    Greater than or equal          Relational
 <=    Less than or equal             operators
 >     Greater than
 <     Less than
 &&    logical (sequential) and
                                       Logical
 ||    logical (sequential) or         operators
 =     assignment
                      prepared by Taif.A.S.G
Declaration of variables

The general form of declaration of variables:

           Type variable1, variable2,...., variableN;
Example:

int count;
float x,y;
double pi;
char c1,c2,c3;
byte b;
                         prepared by Taif.A.S.G
Giving value to variable

The general form of giving value to variables:

                  variableName= value;
Example:

finalValue=100;
x=y=z=0;
Yes = ‘x’;



                         prepared by Taif.A.S.G
Simple programs
 Write C++ Program to find Sum and Average of two
  numbers?

Write C++ Program to find area of a circle?




                    prepared by Taif.A.S.G
C++ statement
                                Control
                              statement
     Selection                     iteration                   jump
     statement                    statement                  statement



If    if-else   switch      for      while   do      break   continue   return


                            prepared by Taif.A.S.G
Decision making
• C++ supports the following statements Known
  as control or decision making statements.
1. if statement.
2. switch statement.
3. Conditional operator ? : statement.




                  prepared by Taif.A.S.G    14
Decision making with if
                statement
The general form of simple if statement is :
                if (<conditional expression>)
                <statement action>

Example:

       if (a > b)
       cout<<"a > b";




                            prepared by Taif.A.S.G   15
Decision making with if
            statement cont..
The general form of simple if else statement is :
                if (<conditional expression>)
                <statement action>
                else
Example:        <statement action>

       if (a > b)
       cout<<" a > b";
       else
       cout<<"a<b";

                            prepared by Taif.A.S.G   16
Decision making with if
            statement cont..
The general form of Multiple if else statement is :
                  if (<conditional expression>)
                  <statement action>
                  else if (<conditional expression>)
                  <statement action>
                  else
Example:          <statement action>
if (a > b)
cout<<" a > b";
 else if (a< b)
 cout<<"b > a";
else
 cout<<" a=b";
                              prepared by Taif.A.S.G   17
Decision making with switch
          statement
• The if statement allows you to select one of
  two sections of code to execute based on a
  boolean value (only two possible values). The
  switch statement allows you to choose from
  many statements.




                    prepared by Taif.A.S.G        18
Decision making with switch
         statement cont..
switch (expr) {
case c1:
statements // do these if expr == c1
 break;
case c2:
statements // do these if expr == c2
 break;
 case c3:
case c4: // Cases can simply fall thru.
statements // do these if expr == any of c's
 break; . . .
default:      // OPTIONAL
statements // do these if expr != any above
 }

                                   prepared by Taif.A.S.G   19
The ? : Operator:
• can be used to replace if...else statements. It has
  the following general form:
  Exp1 ? Exp2 : Exp3;
  Where Exp1, Exp2, and Exp3 are expressions.
• The value of a ? expression is determined like
  this: Exp1 is condition evaluated. If it is true, then
  Exp2 is evaluated and becomes the value of the
  entire ? expression. If Exp1 is false, then Exp3 is
  evaluated and its value becomes the value of the
  expression.
                       prepared by Taif.A.S.G         20
Simple programs
 Write C++ Program to find Number is Positive or
  Negative?

Write C++ Program to find the Grade of student ?

 Write C++ Program to check the day of week by using
  SWITCH-CASE?




                   prepared by Taif.A.S.G
Looping
The C++ language provides three constructs for
  performing loop operations, there are:
   1. The for statement.
   2. The while statement.
   3. The do statement.




                   prepared by Taif.A.S.G        22
Looping cont..
The general form of for statement:

for (initialization; test condition; increment)
 {
    Body of loop
 }


Example:
for( x=0; x<=10; x++)
{
cout<<x;
}                          prepared by Taif.A.S.G   23
Looping cont..
The general form of while statement:
       initialization;
      while(test condition)
     {
    Body of loop
    }

Example:
x=0;
while(x<=10)
{
cout<<x;
x++; }                     prepared by Taif.A.S.G   24
Looping cont..
The general form of do statement:
       initialization;
      do
     {
    Body of loop
    }
   while(test condition);

Example:
x=0;
do
{
cout<<x;
x++; }
while(x<=10) ;            prepared by Taif.A.S.G   25
Int num2        Int num1
                                                             0               0
  Nested Looping                                                             1
for(num2 = 0; num2 <= 3; num2++)                                             2
{                                                                       3 end of loop
   for(num1 = 0; num1 <= 2; num1++)                          1               0
   {                                                                         1
       cout<<num2 << " " <<num1;
                                                                             2
   }
}                                                                       3 end of loop
                                                             2               0
                                                                             1
                                                                             2
                                                                        3 end of loop
                                                             3               0
                                                                             1
                                                                             2
                                                                        3 end of loop
                               prepared by Taif.A.S.G                               26
                                                        4 End of loop
Functions
• A complex problem is often easier to solve by
  dividing it into several smaller
  parts(Modules), each of which can be solved by
  itself. This is called structured programming.
• In C++ Modules Known as Functions & Classes
• main() then uses these functions to solve the
  original problem.


                   prepared by Taif.A.S.G     27
Functions (cont..)
• C++ allows the use of both internal (user-
  defined) and external functions.

• External functions (e.g., abs, ceil, rand,
  sqrt, etc.) are usually grouped into specialized
  libraries (e.g., iostream, stdlib, math,
  etc.)


                     prepared by Taif.A.S.G          28
Function prototype
• The function prototype declares the input and output
  parameters of the function.

• The function prototype has the following syntax:
     <type> <function name>(<type list>);

• Example: A function that returns the absolute value of
  an integer is: int absolute(int);
• If a function definition is placed in front of main(),
  there is no need to include its function prototype.


                       prepared by Taif.A.S.G            29
Function Definition
• A function definition has the following syntax:
  <type> <function name>(<parameter list>){
       <local declarations>
       <sequence of statements>
  }

• For example: Definition of a function that computes the absolute
  value of an integer:

int absolute(int x){
     if (x >= 0) return x;
     else        return -x;
}

• The function definition can be placed anywhere in the program.

                            prepared by Taif.A.S.G                   30
Function call

• A function call has the following syntax:
  <function name>(<argument list>)


  Example: int distance = absolute(-5);




                      prepared by Taif.A.S.G   31

More Related Content

What's hot

What's hot (20)

Strings in c++
Strings in c++Strings in c++
Strings in c++
 
Intro to c++
Intro to c++Intro to c++
Intro to c++
 
Control structures in C++ Programming Language
Control structures in C++ Programming LanguageControl structures in C++ Programming Language
Control structures in C++ Programming Language
 
Standard Library Functions
Standard Library FunctionsStandard Library Functions
Standard Library Functions
 
Operator in c programming
Operator in c programmingOperator in c programming
Operator in c programming
 
Polymorphism In c++
Polymorphism In c++Polymorphism In c++
Polymorphism In c++
 
Control statements in c
Control statements in cControl statements in c
Control statements in c
 
Operators and expressions in C++
Operators and expressions in C++Operators and expressions in C++
Operators and expressions in C++
 
Introduction to cpp
Introduction to cppIntroduction to cpp
Introduction to cpp
 
Binary operator overloading
Binary operator overloadingBinary operator overloading
Binary operator overloading
 
Conditional statement c++
Conditional statement c++Conditional statement c++
Conditional statement c++
 
C++ Language
C++ LanguageC++ Language
C++ Language
 
Java program structure
Java program structureJava program structure
Java program structure
 
C++ programming
C++ programmingC++ programming
C++ programming
 
Operator & Expression in c++
Operator & Expression in c++Operator & Expression in c++
Operator & Expression in c++
 
Object-oriented Programming-with C#
Object-oriented Programming-with C#Object-oriented Programming-with C#
Object-oriented Programming-with C#
 
Recursive Function
Recursive FunctionRecursive Function
Recursive Function
 
Library functions in c++
Library functions in c++Library functions in c++
Library functions in c++
 
Programming in C Basics
Programming in C BasicsProgramming in C Basics
Programming in C Basics
 
C++
C++C++
C++
 

Viewers also liked

C++ programming intro
C++ programming introC++ programming intro
C++ programming intromarklaloo
 
Introduction to C++
Introduction to C++ Introduction to C++
Introduction to C++ Bharat Kalia
 
History of C/C++ Language
History of C/C++ LanguageHistory of C/C++ Language
History of C/C++ LanguageFarid Hilal
 
CReVote: un système de vote électronique résistant à la coercition basé sur l...
CReVote: un système de vote électronique résistant à la coercition basé sur l...CReVote: un système de vote électronique résistant à la coercition basé sur l...
CReVote: un système de vote électronique résistant à la coercition basé sur l...pacomeambassa
 
CBSE Class XI Programming in C++
CBSE Class XI Programming in C++CBSE Class XI Programming in C++
CBSE Class XI Programming in C++Pranav Ghildiyal
 
Multidimensional arrays in C++
Multidimensional arrays in C++Multidimensional arrays in C++
Multidimensional arrays in C++Ilio Catallo
 
Presentation on C++ Programming Language
Presentation on C++ Programming LanguagePresentation on C++ Programming Language
Presentation on C++ Programming Languagesatvirsandhu9
 
LESS, Le CSS avancé
LESS, Le CSS avancéLESS, Le CSS avancé
LESS, Le CSS avancéMahmoud Nbet
 
Cs1123 3 c++ overview
Cs1123 3 c++ overviewCs1123 3 c++ overview
Cs1123 3 c++ overviewTAlha MAlik
 
Overview of c++
Overview of c++Overview of c++
Overview of c++geeeeeet
 
Understand Decision structures in c++ (cplusplus)
Understand Decision structures in c++ (cplusplus)Understand Decision structures in c++ (cplusplus)
Understand Decision structures in c++ (cplusplus)Muhammad Tahir Bashir
 
difference between c c++ c#
difference between c c++ c#difference between c c++ c#
difference between c c++ c#Sireesh K
 
Cours php & Mysql - 4éme partie
Cours php & Mysql - 4éme partieCours php & Mysql - 4éme partie
Cours php & Mysql - 4éme partiekadzaki
 
Cours php & Mysql - 5éme partie
Cours php & Mysql - 5éme partieCours php & Mysql - 5éme partie
Cours php & Mysql - 5éme partiekadzaki
 

Viewers also liked (20)

C++
C++C++
C++
 
C++ programming intro
C++ programming introC++ programming intro
C++ programming intro
 
Introduction Of C++
Introduction Of C++Introduction Of C++
Introduction Of C++
 
Introduction to C++
Introduction to C++ Introduction to C++
Introduction to C++
 
History of C/C++ Language
History of C/C++ LanguageHistory of C/C++ Language
History of C/C++ Language
 
CReVote: un système de vote électronique résistant à la coercition basé sur l...
CReVote: un système de vote électronique résistant à la coercition basé sur l...CReVote: un système de vote électronique résistant à la coercition basé sur l...
CReVote: un système de vote électronique résistant à la coercition basé sur l...
 
CBSE Class XI Programming in C++
CBSE Class XI Programming in C++CBSE Class XI Programming in C++
CBSE Class XI Programming in C++
 
C vs c++
C vs c++C vs c++
C vs c++
 
Multidimensional arrays in C++
Multidimensional arrays in C++Multidimensional arrays in C++
Multidimensional arrays in C++
 
Presentation on C++ Programming Language
Presentation on C++ Programming LanguagePresentation on C++ Programming Language
Presentation on C++ Programming Language
 
LESS, Le CSS avancé
LESS, Le CSS avancéLESS, Le CSS avancé
LESS, Le CSS avancé
 
Cs1123 3 c++ overview
Cs1123 3 c++ overviewCs1123 3 c++ overview
Cs1123 3 c++ overview
 
C vs c++
C vs c++C vs c++
C vs c++
 
C++ Overview PPT
C++ Overview PPTC++ Overview PPT
C++ Overview PPT
 
Overview of c++
Overview of c++Overview of c++
Overview of c++
 
Understand Decision structures in c++ (cplusplus)
Understand Decision structures in c++ (cplusplus)Understand Decision structures in c++ (cplusplus)
Understand Decision structures in c++ (cplusplus)
 
difference between c c++ c#
difference between c c++ c#difference between c c++ c#
difference between c c++ c#
 
Cours php & Mysql - 4éme partie
Cours php & Mysql - 4éme partieCours php & Mysql - 4éme partie
Cours php & Mysql - 4éme partie
 
C++ language
C++ languageC++ language
C++ language
 
Cours php & Mysql - 5éme partie
Cours php & Mysql - 5éme partieCours php & Mysql - 5éme partie
Cours php & Mysql - 5éme partie
 

Similar to Overview of c++ language

C++ decision making
C++ decision makingC++ decision making
C++ decision makingZohaib Ahmed
 
[C++][a] tutorial 2
[C++][a] tutorial 2[C++][a] tutorial 2
[C++][a] tutorial 2yasir_cesc
 
Control Structures in C
Control Structures in CControl Structures in C
Control Structures in Csana shaikh
 
Programming Fundamentals lecture 8
Programming Fundamentals lecture 8Programming Fundamentals lecture 8
Programming Fundamentals lecture 8REHAN IJAZ
 
FP 201 - Unit 3 Part 2
FP 201 - Unit 3 Part 2FP 201 - Unit 3 Part 2
FP 201 - Unit 3 Part 2rohassanie
 
Object oriented programming system with C++
Object oriented programming system with C++Object oriented programming system with C++
Object oriented programming system with C++msharshitha03s
 
Btech i pic u-3 handling input output and control statements
Btech i pic u-3 handling input output and control statementsBtech i pic u-3 handling input output and control statements
Btech i pic u-3 handling input output and control statementsRai University
 
handling input output and control statements
 handling input output and control statements handling input output and control statements
handling input output and control statementsRai University
 
Mca i pic u-3 handling input output and control statements
Mca i pic u-3 handling input output and control statementsMca i pic u-3 handling input output and control statements
Mca i pic u-3 handling input output and control statementsRai University
 
Good news, everybody! Guile 2.2 performance notes (FOSDEM 2016)
Good news, everybody! Guile 2.2 performance notes (FOSDEM 2016)Good news, everybody! Guile 2.2 performance notes (FOSDEM 2016)
Good news, everybody! Guile 2.2 performance notes (FOSDEM 2016)Igalia
 
C Programming Language Part 6
C Programming Language Part 6C Programming Language Part 6
C Programming Language Part 6Rumman Ansari
 
Loops in c language
Loops in c languageLoops in c language
Loops in c languagetanmaymodi4
 

Similar to Overview of c++ language (20)

C++ decision making
C++ decision makingC++ decision making
C++ decision making
 
Looping statements
Looping statementsLooping statements
Looping statements
 
[C++][a] tutorial 2
[C++][a] tutorial 2[C++][a] tutorial 2
[C++][a] tutorial 2
 
lesson 2.pptx
lesson 2.pptxlesson 2.pptx
lesson 2.pptx
 
Control Structures in C
Control Structures in CControl Structures in C
Control Structures in C
 
Programming Fundamentals lecture 8
Programming Fundamentals lecture 8Programming Fundamentals lecture 8
Programming Fundamentals lecture 8
 
FP 201 - Unit 3 Part 2
FP 201 - Unit 3 Part 2FP 201 - Unit 3 Part 2
FP 201 - Unit 3 Part 2
 
Iteration
IterationIteration
Iteration
 
Session 3
Session 3Session 3
Session 3
 
C++ programming
C++ programmingC++ programming
C++ programming
 
Object oriented programming system with C++
Object oriented programming system with C++Object oriented programming system with C++
Object oriented programming system with C++
 
C++ programming
C++ programmingC++ programming
C++ programming
 
C operators
C operatorsC operators
C operators
 
Btech i pic u-3 handling input output and control statements
Btech i pic u-3 handling input output and control statementsBtech i pic u-3 handling input output and control statements
Btech i pic u-3 handling input output and control statements
 
handling input output and control statements
 handling input output and control statements handling input output and control statements
handling input output and control statements
 
Mca i pic u-3 handling input output and control statements
Mca i pic u-3 handling input output and control statementsMca i pic u-3 handling input output and control statements
Mca i pic u-3 handling input output and control statements
 
Good news, everybody! Guile 2.2 performance notes (FOSDEM 2016)
Good news, everybody! Guile 2.2 performance notes (FOSDEM 2016)Good news, everybody! Guile 2.2 performance notes (FOSDEM 2016)
Good news, everybody! Guile 2.2 performance notes (FOSDEM 2016)
 
C fundamental
C fundamentalC fundamental
C fundamental
 
C Programming Language Part 6
C Programming Language Part 6C Programming Language Part 6
C Programming Language Part 6
 
Loops in c language
Loops in c languageLoops in c language
Loops in c language
 

Recently uploaded

How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
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
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
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
 
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
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
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
 
“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
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
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
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
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
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 

Recently uploaded (20)

How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
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
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
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
 
“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...
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
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
 
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
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
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 ...
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 

Overview of c++ language

  • 1. Overview of C++ language
  • 2. Lecture’s outline What is C++? Identifiers. Constant Semicolons & Blocks in C++ Data type Comments Operator Declaration of variables Giving value to variable C++ statements prepared by Taif.A.S.G
  • 3. What is C++? • Developed by Bjarne Stroustrup (in 1979 at Bell Labs) • C++ is regarded as a middle-level language, as it comprises a combination of both high-level and low-level language features. • C++ is a statically typed, compiled, general purpose, case- sensitive, free-form programming language that supports procedural, object-oriented, and generic programming. • C++ is a superset of C that enhancement to the C language and originally named C with Classes but later it was renamed C++. prepared by Taif.A.S.G
  • 4. identifiers They are used for naming classes function, module, variables, object in a program. They follow the following rules: 1) They can have alphabets , digits, and the underscore(_). 2) They must not begin with a digit. 3) Uppercase and lowercase are distinct. 4) They can be of any length. 5) It should not be a keyword. 6) White space is not allowed. prepared by Taif.A.S.G
  • 5. Constant Constant is one whose value cannot be changed after it has been initialized-any attempt to assign to field will produce a compile-error .So, we can declare the constant by using const field and use all uppercase letter. Syntax of declare the constant is: const type name=value Example: const int STRENGTH = 100; const float PI = 3.14; prepared by Taif.A.S.G
  • 6. Semicolons & Blocks in C++: • In C++, the semicolon is a statement terminator. That is, each individual statement must be ended with a semicolon. It indicates the end of one logical entity. • For example: following are two different statements: x = y; y = y+1; prepared by Taif.A.S.G 6
  • 8. Comments C++ can use both the single line comments and multi-line comments . single line comments begin with // and end at the end of line. For longer comments we can create multi-line comments by starting with /* and ending with */ prepared by Taif.A.S.G
  • 9. Operator * / % + - are the mathematical operators * / % have a higher precedence than + or – mathematical operators ++ Increment operator –– Decrement operator == Equal (careful) != Not equal >= Greater than or equal Relational <= Less than or equal operators > Greater than < Less than && logical (sequential) and Logical || logical (sequential) or operators = assignment prepared by Taif.A.S.G
  • 10. Declaration of variables The general form of declaration of variables: Type variable1, variable2,...., variableN; Example: int count; float x,y; double pi; char c1,c2,c3; byte b; prepared by Taif.A.S.G
  • 11. Giving value to variable The general form of giving value to variables: variableName= value; Example: finalValue=100; x=y=z=0; Yes = ‘x’; prepared by Taif.A.S.G
  • 12. Simple programs  Write C++ Program to find Sum and Average of two numbers? Write C++ Program to find area of a circle? prepared by Taif.A.S.G
  • 13. C++ statement Control statement Selection iteration jump statement statement statement If if-else switch for while do break continue return prepared by Taif.A.S.G
  • 14. Decision making • C++ supports the following statements Known as control or decision making statements. 1. if statement. 2. switch statement. 3. Conditional operator ? : statement. prepared by Taif.A.S.G 14
  • 15. Decision making with if statement The general form of simple if statement is : if (<conditional expression>) <statement action> Example: if (a > b) cout<<"a > b"; prepared by Taif.A.S.G 15
  • 16. Decision making with if statement cont.. The general form of simple if else statement is : if (<conditional expression>) <statement action> else Example: <statement action> if (a > b) cout<<" a > b"; else cout<<"a<b"; prepared by Taif.A.S.G 16
  • 17. Decision making with if statement cont.. The general form of Multiple if else statement is : if (<conditional expression>) <statement action> else if (<conditional expression>) <statement action> else Example: <statement action> if (a > b) cout<<" a > b"; else if (a< b) cout<<"b > a"; else cout<<" a=b"; prepared by Taif.A.S.G 17
  • 18. Decision making with switch statement • The if statement allows you to select one of two sections of code to execute based on a boolean value (only two possible values). The switch statement allows you to choose from many statements. prepared by Taif.A.S.G 18
  • 19. Decision making with switch statement cont.. switch (expr) { case c1: statements // do these if expr == c1 break; case c2: statements // do these if expr == c2 break; case c3: case c4: // Cases can simply fall thru. statements // do these if expr == any of c's break; . . . default: // OPTIONAL statements // do these if expr != any above } prepared by Taif.A.S.G 19
  • 20. The ? : Operator: • can be used to replace if...else statements. It has the following general form: Exp1 ? Exp2 : Exp3; Where Exp1, Exp2, and Exp3 are expressions. • The value of a ? expression is determined like this: Exp1 is condition evaluated. If it is true, then Exp2 is evaluated and becomes the value of the entire ? expression. If Exp1 is false, then Exp3 is evaluated and its value becomes the value of the expression. prepared by Taif.A.S.G 20
  • 21. Simple programs  Write C++ Program to find Number is Positive or Negative? Write C++ Program to find the Grade of student ?  Write C++ Program to check the day of week by using SWITCH-CASE? prepared by Taif.A.S.G
  • 22. Looping The C++ language provides three constructs for performing loop operations, there are: 1. The for statement. 2. The while statement. 3. The do statement. prepared by Taif.A.S.G 22
  • 23. Looping cont.. The general form of for statement: for (initialization; test condition; increment) { Body of loop } Example: for( x=0; x<=10; x++) { cout<<x; } prepared by Taif.A.S.G 23
  • 24. Looping cont.. The general form of while statement: initialization; while(test condition) { Body of loop } Example: x=0; while(x<=10) { cout<<x; x++; } prepared by Taif.A.S.G 24
  • 25. Looping cont.. The general form of do statement: initialization; do { Body of loop } while(test condition); Example: x=0; do { cout<<x; x++; } while(x<=10) ; prepared by Taif.A.S.G 25
  • 26. Int num2 Int num1 0 0 Nested Looping 1 for(num2 = 0; num2 <= 3; num2++) 2 { 3 end of loop for(num1 = 0; num1 <= 2; num1++) 1 0 { 1 cout<<num2 << " " <<num1; 2 } } 3 end of loop 2 0 1 2 3 end of loop 3 0 1 2 3 end of loop prepared by Taif.A.S.G 26 4 End of loop
  • 27. Functions • A complex problem is often easier to solve by dividing it into several smaller parts(Modules), each of which can be solved by itself. This is called structured programming. • In C++ Modules Known as Functions & Classes • main() then uses these functions to solve the original problem. prepared by Taif.A.S.G 27
  • 28. Functions (cont..) • C++ allows the use of both internal (user- defined) and external functions. • External functions (e.g., abs, ceil, rand, sqrt, etc.) are usually grouped into specialized libraries (e.g., iostream, stdlib, math, etc.) prepared by Taif.A.S.G 28
  • 29. Function prototype • The function prototype declares the input and output parameters of the function. • The function prototype has the following syntax: <type> <function name>(<type list>); • Example: A function that returns the absolute value of an integer is: int absolute(int); • If a function definition is placed in front of main(), there is no need to include its function prototype. prepared by Taif.A.S.G 29
  • 30. Function Definition • A function definition has the following syntax: <type> <function name>(<parameter list>){ <local declarations> <sequence of statements> } • For example: Definition of a function that computes the absolute value of an integer: int absolute(int x){ if (x >= 0) return x; else return -x; } • The function definition can be placed anywhere in the program. prepared by Taif.A.S.G 30
  • 31. Function call • A function call has the following syntax: <function name>(<argument list>) Example: int distance = absolute(-5); prepared by Taif.A.S.G 31