SlideShare a Scribd company logo
1 of 29
C++
    SUBMITTED BY-RAJANDEEP KAUR
          ROLL NO- 115332
        BRANCH- CSE (2nd SEM)

SUBMITTED TO- Er. JAGDEEP SINGH MALHI
1
         The Task of Programming

►   Programming a computer involves writing
    instructions that enable a computer to carry
    out a single task or a group of tasks
►   A computer programming language requires
    learning both vocabulary and syntax
►   Programmers use many different programming
    languages, including BASIC, Pascal, COBOL,
    RPG, and C++
►   The rules of any language make up its syntax
►   Machine language is the language that
    computers can understand; it consists of 1s
    and 0s
1
        The Task of Programming

►A  translator (called either a compiler or an
  interpreter) checks your program for syntax
  errors
► A logical error occurs when you use a
  statement that, although syntactically
  correct, doesn’t do what you intended
► You run a program by issuing a command to
  execute the program statements
► You test a program by using sample data to
  determine whether the program results are
  correct
1
            Procedural Programming

►   Procedural programs consist of a series of steps or
    procedures that take place one after the other
►   The programmer determines the exact conditions
    under which a procedure takes place, how often it
    takes place, and when the program stops
►   Programmers write procedural programs in many
    programming languages, such as COBOL, BASIC,
    FORTRAN, and RPG
►   You can also write procedural programs in C++
1
        A main( ) Function in C++

►   C++ programs consist of modules called
    functions
►   Every statement within every C++ program is
    contained in a function
►   Every function consists of two parts:
     A function header is the initial line of code in a C++
      which always has three parts:
       ► Return type of the function
       ► Name of the function
       ► Types and names of any variables enclosed in
         parentheses, and which the function receives
     A function body
1
         Creating a main( ) Function




►   Every complete C++ statement ends with a
    semicolon
►   Often several statements must be grouped
    together, as when several statements must occur in
    a loop
►   In such a case, the statements have their own set
    of opening and closing braces within the main
    braces, forming a block
1
          Working with Variables

►   In C++, you must name and give a type to
    variables (sometimes called identifiers) before
    you can use them
►   Names of C++ variables can include letters,
    numbers, and underscores, but must begin
    with a letter or underscore
►   No spaces or other special characters are
    allowed within a C++ variable name
►   Every programming language contains a few
    vocabulary words, or keywords, that you need
    in order to use the language
Common C++ Keywords
1
           Working with Variables

►   A C++ keyword cannot be used as a variable
    name
►   Each named variable must have a type
►   C++ supports three simple types:
     Integer      — Floating point   — Character
►   An integer is a whole number, either positive
    or negative
►   An integer value may be stored in an integer
    variable declared with the keyword int
►   You can also declare an integer variable using
    short int and long int
1
           Working with Variables
►   Explicitly stating the value of a variable is
    called assignment, and is achieved with the
    assignment operator =
►   The variable finalScore is declared and
    assigned a value at the same time
►   Assigning a value to a variable upon creation is
    often referred to as initializing the variable
1
            Creating Comments

► A line comment begins with two slashes (//) and
  continues to the end of the line on which it is
  placed
► A block comment begins with a single slash and an
  asterisk (/*) and ends with an asterisk and a slash
  (*/); it might be contained on a single line or
  continued across many lines
1            Using Libraries and
           Preprocessor Directives
►   Header files are files that contain predefined
    values and routines, such as sqrt( )
►   Their filenames usually end in .h
►   In order for your C++ program to use these
    predefined routines, you must include a
    preprocessor directive, a statement that tells
    the compiler what to do before compiling the
    program
►   In C++, all preprocessor directives begin with
    a pound sign (#), which is also called an
    octothorp
►   The #include preprocessor directive tells the
    compiler to include a file as part of the finished
    product
2
        C++ Binary Arithmetic Operators

►   Often after data values are input, you perform
    calculations with them
►   C++ provides five simple arithmetic operators
    for creating arithmetic expressions:
       addition (+)         – subtraction (-)
       multiplication (*)          – division (/)
       modulus (%)
►   Each of these arithmetic operators is a binary
    operator; each takes two operands, one on each
    side of the operator, as in 12 + 9 or 16.2*1.5
►   The results of an arithmetic operation can be
    stored in memory
2
         Shortcut Arithmetic Operators
►   As you might expect, you can use two minus
    signs (--) before or after a variable to
    decrement it
2
        Shortcut Arithmetic Operators

►   The prefix and postfix increment and decrement
    operators are examples of unary operators
►   Unary operators are those that require only one
    operand, such as num in the expression ++num
►   When an expression includes a prefix operator, the
    mathematical operation takes place before the
    expression is evaluated
►   When an expression includes a postfix operator, the
    mathematical operation takes place after the
    expression is evaluated
2
     Shortcut Arithmetic Operators

► Thedifference between the results
 produced by the prefix and postfix
 operators can be subtle, but the
 outcome of a program can vary greatly
 depending on which increment
 operator you use in an expression
2
        Evaluating Boolean Expressions
►   The unary operator ! Means not, and essentially reverses
    the true/false value of an expression
2
                         Selection

►   Computer programs seem smart because of
    their ability to use selections or make decisions
►   C++ lets you perform selections in a number of
    ways:
     The if statement
     The switch statement
     The if operator
     Logical AND and Logical OR
2        Some Sample Selection
    Statements within a C++ Program
2
               The if Statement

►   Any C++ expression can be evaluated as part of
    an if statement
2
            The switch Statement
► When you want to create different outcomes
  depending on specific values of a variable, you can
  use a series of ifs shown in the program statement in
  Figure 2-14
► As an alternative to the long string of ifs shown in
  Figure 2-14, you can use the switch statement
► The switch can contain any number of cases in any
  order
2
                    The if Operator

►   Another alternative to the if statement involves the if
    operator (also called the conditional operator), which is
    represented by a question mark (?)
►   E.g.
►   cout<<(driveAge<26)?”The driver is under 26”:”The
    driver is at least 26”;
►   The if operator provides a concise way to express two
    alternatives
►   The conditional operator is an example of a ternary
    operator, one that takes three operands instead of just
    one or two
2
        Logical AND and Logical OR

►   In some programming situations, two or more
    conditions must be true to initiate an action
►   Figure 2-16 works correctly using a nested if—
    that is, one if statement within another if
    statement
►   If numVisits is not greater than 5, the
    statement is finished—the second comparison
    does not even take place
►   Alternatively, a logical AND (&&) can be used,
    as shown in Figure 2-17
2
    Logical AND and Logical OR
2
            Using the Logical OR

► In certain programming situations, only one of
  two alternatives must be true for some action to
  take place
► A logical OR (||) could also be used
► A logical OR is a compound boolean expression in
  which either of two conditions must be true for
  the entire expression to evaluate as true
► Table 2-4 shows how C++ evaluates any
  expression that uses the || operator
2
    Using the Logical OR
2
                  The while Loop

►   Loops provide a mechanism with which to
    perform statements repeatedly and, just as
    important, to stop that performance when
    warranted
    while (boolean expression)
     statement;
►   In C++, the while statement can be used to loop
►   The variable count, shown in the program in
    Figure 2-21, is often called a loop-control
    variable, because it is the value of count that
    controls whether the loop body continues to
    execute
2
                   The for Statement

► The for statement represents an alternative to the while
  statement
► It is most often used in a definite loop, or a loop that must
  execute a definite number of times
► It takes the form:
    for (initialize; evaluate; alter)
       statement;
Thanks

More Related Content

What's hot

C LANGUAGE - BESTECH SOLUTIONS
C LANGUAGE - BESTECH SOLUTIONSC LANGUAGE - BESTECH SOLUTIONS
C LANGUAGE - BESTECH SOLUTIONSBESTECH SOLUTIONS
 
Basic structure of c programming
Basic structure of c programmingBasic structure of c programming
Basic structure of c programmingTejaswiB4
 
Recursive Function
Recursive FunctionRecursive Function
Recursive FunctionHarsh Pathak
 
Lecture 16 17 code-generation
Lecture 16 17 code-generationLecture 16 17 code-generation
Lecture 16 17 code-generationIffat Anjum
 
C language for Semester Exams for Engineers
C language for Semester Exams for Engineers C language for Semester Exams for Engineers
C language for Semester Exams for Engineers Appili Vamsi Krishna
 
C Programming Language Tutorial for beginners - JavaTpoint
C Programming Language Tutorial for beginners - JavaTpointC Programming Language Tutorial for beginners - JavaTpoint
C Programming Language Tutorial for beginners - JavaTpointJavaTpoint.Com
 
Ch10 Program Organization
Ch10 Program OrganizationCh10 Program Organization
Ch10 Program OrganizationSzeChingChen
 
Overview of c++ language
Overview of c++ language   Overview of c++ language
Overview of c++ language samt7
 
Programming in C Presentation upto FILE
Programming in C Presentation upto FILEProgramming in C Presentation upto FILE
Programming in C Presentation upto FILEDipta Saha
 
Introduction to c programming
Introduction to c programmingIntroduction to c programming
Introduction to c programminggajendra singh
 
Control Flow Analysis
Control Flow AnalysisControl Flow Analysis
Control Flow AnalysisEdgar Barbosa
 
Intermediate code- generation
Intermediate code- generationIntermediate code- generation
Intermediate code- generationrawan_z
 
Algorithm and c language
Algorithm and c languageAlgorithm and c language
Algorithm and c languagekamalbeydoun
 
User defined functions in C programmig
User defined functions in C programmigUser defined functions in C programmig
User defined functions in C programmigAppili Vamsi Krishna
 
Datastructure notes
Datastructure notesDatastructure notes
Datastructure notesSrikanth
 

What's hot (20)

C LANGUAGE - BESTECH SOLUTIONS
C LANGUAGE - BESTECH SOLUTIONSC LANGUAGE - BESTECH SOLUTIONS
C LANGUAGE - BESTECH SOLUTIONS
 
Basic structure of c programming
Basic structure of c programmingBasic structure of c programming
Basic structure of c programming
 
Recursive Function
Recursive FunctionRecursive Function
Recursive Function
 
Lecture 16 17 code-generation
Lecture 16 17 code-generationLecture 16 17 code-generation
Lecture 16 17 code-generation
 
C language for Semester Exams for Engineers
C language for Semester Exams for Engineers C language for Semester Exams for Engineers
C language for Semester Exams for Engineers
 
Compiler unit 4
Compiler unit 4Compiler unit 4
Compiler unit 4
 
C programming session8
C programming  session8C programming  session8
C programming session8
 
C Programming Language Tutorial for beginners - JavaTpoint
C Programming Language Tutorial for beginners - JavaTpointC Programming Language Tutorial for beginners - JavaTpoint
C Programming Language Tutorial for beginners - JavaTpoint
 
Ch10 Program Organization
Ch10 Program OrganizationCh10 Program Organization
Ch10 Program Organization
 
Overview of c++ language
Overview of c++ language   Overview of c++ language
Overview of c++ language
 
Programming in C Presentation upto FILE
Programming in C Presentation upto FILEProgramming in C Presentation upto FILE
Programming in C Presentation upto FILE
 
Cpp functions
Cpp functionsCpp functions
Cpp functions
 
Introduction to c programming
Introduction to c programmingIntroduction to c programming
Introduction to c programming
 
Control Flow Analysis
Control Flow AnalysisControl Flow Analysis
Control Flow Analysis
 
User defined functions
User defined functionsUser defined functions
User defined functions
 
Function in C program
Function in C programFunction in C program
Function in C program
 
Intermediate code- generation
Intermediate code- generationIntermediate code- generation
Intermediate code- generation
 
Algorithm and c language
Algorithm and c languageAlgorithm and c language
Algorithm and c language
 
User defined functions in C programmig
User defined functions in C programmigUser defined functions in C programmig
User defined functions in C programmig
 
Datastructure notes
Datastructure notesDatastructure notes
Datastructure notes
 

Similar to C++ rajan

01 c++ Intro.ppt
01 c++ Intro.ppt01 c++ Intro.ppt
01 c++ Intro.pptTareq Hasan
 
1588147798Begining_ABUAD1.pdf
1588147798Begining_ABUAD1.pdf1588147798Begining_ABUAD1.pdf
1588147798Begining_ABUAD1.pdfSemsemSameer1
 
Esoft Metro Campus - Programming with C++
Esoft Metro Campus - Programming with C++Esoft Metro Campus - Programming with C++
Esoft Metro Campus - Programming with C++Rasan Samarasinghe
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAAiman Hud
 
C Language (All Concept)
C Language (All Concept)C Language (All Concept)
C Language (All Concept)sachindane
 
C++ programming language basic to advance level
C++ programming language basic to advance levelC++ programming language basic to advance level
C++ programming language basic to advance levelsajjad ali khan
 
c_programming.pdf
c_programming.pdfc_programming.pdf
c_programming.pdfHome
 
Complete C++ programming Language Course
Complete C++ programming Language CourseComplete C++ programming Language Course
Complete C++ programming Language CourseVivek chan
 
UNIT-1 notes(Data Types – Variables – Operations – Expressions and Statements...
UNIT-1 notes(Data Types – Variables – Operations – Expressions and Statements...UNIT-1 notes(Data Types – Variables – Operations – Expressions and Statements...
UNIT-1 notes(Data Types – Variables – Operations – Expressions and Statements...RSathyaPriyaCSEKIOT
 
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
 
session-1_Design_Analysis_Algorithm.pptx
session-1_Design_Analysis_Algorithm.pptxsession-1_Design_Analysis_Algorithm.pptx
session-1_Design_Analysis_Algorithm.pptxchandankumar364348
 

Similar to C++ rajan (20)

01 c++ Intro.ppt
01 c++ Intro.ppt01 c++ Intro.ppt
01 c++ Intro.ppt
 
Introduction%20C.pptx
Introduction%20C.pptxIntroduction%20C.pptx
Introduction%20C.pptx
 
1588147798Begining_ABUAD1.pdf
1588147798Begining_ABUAD1.pdf1588147798Begining_ABUAD1.pdf
1588147798Begining_ABUAD1.pdf
 
Esoft Metro Campus - Programming with C++
Esoft Metro Campus - Programming with C++Esoft Metro Campus - Programming with C++
Esoft Metro Campus - Programming with C++
 
Programming in C
Programming in CProgramming in C
Programming in C
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
 
C Language (All Concept)
C Language (All Concept)C Language (All Concept)
C Language (All Concept)
 
#Code2 create c++ for beginners
#Code2 create  c++ for beginners #Code2 create  c++ for beginners
#Code2 create c++ for beginners
 
C Programming Unit-2
C Programming Unit-2C Programming Unit-2
C Programming Unit-2
 
Lecture 2
Lecture 2Lecture 2
Lecture 2
 
85ec7 session2 c++
85ec7 session2 c++85ec7 session2 c++
85ec7 session2 c++
 
C Programming Unit-1
C Programming Unit-1C Programming Unit-1
C Programming Unit-1
 
C++ programming language basic to advance level
C++ programming language basic to advance levelC++ programming language basic to advance level
C++ programming language basic to advance level
 
Chap 3 c++
Chap 3 c++Chap 3 c++
Chap 3 c++
 
c_programming.pdf
c_programming.pdfc_programming.pdf
c_programming.pdf
 
Complete C++ programming Language Course
Complete C++ programming Language CourseComplete C++ programming Language Course
Complete C++ programming Language Course
 
UNIT-1 notes(Data Types – Variables – Operations – Expressions and Statements...
UNIT-1 notes(Data Types – Variables – Operations – Expressions and Statements...UNIT-1 notes(Data Types – Variables – Operations – Expressions and Statements...
UNIT-1 notes(Data Types – Variables – Operations – Expressions and Statements...
 
C++ decision making
C++ decision makingC++ decision making
C++ decision making
 
[C++][a] tutorial 2
[C++][a] tutorial 2[C++][a] tutorial 2
[C++][a] tutorial 2
 
session-1_Design_Analysis_Algorithm.pptx
session-1_Design_Analysis_Algorithm.pptxsession-1_Design_Analysis_Algorithm.pptx
session-1_Design_Analysis_Algorithm.pptx
 

Recently uploaded

Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 

Recently uploaded (20)

Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 

C++ rajan

  • 1. C++ SUBMITTED BY-RAJANDEEP KAUR ROLL NO- 115332 BRANCH- CSE (2nd SEM) SUBMITTED TO- Er. JAGDEEP SINGH MALHI
  • 2. 1 The Task of Programming ► Programming a computer involves writing instructions that enable a computer to carry out a single task or a group of tasks ► A computer programming language requires learning both vocabulary and syntax ► Programmers use many different programming languages, including BASIC, Pascal, COBOL, RPG, and C++ ► The rules of any language make up its syntax ► Machine language is the language that computers can understand; it consists of 1s and 0s
  • 3. 1 The Task of Programming ►A translator (called either a compiler or an interpreter) checks your program for syntax errors ► A logical error occurs when you use a statement that, although syntactically correct, doesn’t do what you intended ► You run a program by issuing a command to execute the program statements ► You test a program by using sample data to determine whether the program results are correct
  • 4. 1 Procedural Programming ► Procedural programs consist of a series of steps or procedures that take place one after the other ► The programmer determines the exact conditions under which a procedure takes place, how often it takes place, and when the program stops ► Programmers write procedural programs in many programming languages, such as COBOL, BASIC, FORTRAN, and RPG ► You can also write procedural programs in C++
  • 5. 1 A main( ) Function in C++ ► C++ programs consist of modules called functions ► Every statement within every C++ program is contained in a function ► Every function consists of two parts:  A function header is the initial line of code in a C++ which always has three parts: ► Return type of the function ► Name of the function ► Types and names of any variables enclosed in parentheses, and which the function receives  A function body
  • 6. 1 Creating a main( ) Function ► Every complete C++ statement ends with a semicolon ► Often several statements must be grouped together, as when several statements must occur in a loop ► In such a case, the statements have their own set of opening and closing braces within the main braces, forming a block
  • 7. 1 Working with Variables ► In C++, you must name and give a type to variables (sometimes called identifiers) before you can use them ► Names of C++ variables can include letters, numbers, and underscores, but must begin with a letter or underscore ► No spaces or other special characters are allowed within a C++ variable name ► Every programming language contains a few vocabulary words, or keywords, that you need in order to use the language
  • 9. 1 Working with Variables ► A C++ keyword cannot be used as a variable name ► Each named variable must have a type ► C++ supports three simple types:  Integer — Floating point — Character ► An integer is a whole number, either positive or negative ► An integer value may be stored in an integer variable declared with the keyword int ► You can also declare an integer variable using short int and long int
  • 10. 1 Working with Variables ► Explicitly stating the value of a variable is called assignment, and is achieved with the assignment operator = ► The variable finalScore is declared and assigned a value at the same time ► Assigning a value to a variable upon creation is often referred to as initializing the variable
  • 11. 1 Creating Comments ► A line comment begins with two slashes (//) and continues to the end of the line on which it is placed ► A block comment begins with a single slash and an asterisk (/*) and ends with an asterisk and a slash (*/); it might be contained on a single line or continued across many lines
  • 12. 1 Using Libraries and Preprocessor Directives ► Header files are files that contain predefined values and routines, such as sqrt( ) ► Their filenames usually end in .h ► In order for your C++ program to use these predefined routines, you must include a preprocessor directive, a statement that tells the compiler what to do before compiling the program ► In C++, all preprocessor directives begin with a pound sign (#), which is also called an octothorp ► The #include preprocessor directive tells the compiler to include a file as part of the finished product
  • 13. 2 C++ Binary Arithmetic Operators ► Often after data values are input, you perform calculations with them ► C++ provides five simple arithmetic operators for creating arithmetic expressions:  addition (+) – subtraction (-)  multiplication (*) – division (/)  modulus (%) ► Each of these arithmetic operators is a binary operator; each takes two operands, one on each side of the operator, as in 12 + 9 or 16.2*1.5 ► The results of an arithmetic operation can be stored in memory
  • 14. 2 Shortcut Arithmetic Operators ► As you might expect, you can use two minus signs (--) before or after a variable to decrement it
  • 15. 2 Shortcut Arithmetic Operators ► The prefix and postfix increment and decrement operators are examples of unary operators ► Unary operators are those that require only one operand, such as num in the expression ++num ► When an expression includes a prefix operator, the mathematical operation takes place before the expression is evaluated ► When an expression includes a postfix operator, the mathematical operation takes place after the expression is evaluated
  • 16. 2 Shortcut Arithmetic Operators ► Thedifference between the results produced by the prefix and postfix operators can be subtle, but the outcome of a program can vary greatly depending on which increment operator you use in an expression
  • 17. 2 Evaluating Boolean Expressions ► The unary operator ! Means not, and essentially reverses the true/false value of an expression
  • 18. 2 Selection ► Computer programs seem smart because of their ability to use selections or make decisions ► C++ lets you perform selections in a number of ways:  The if statement  The switch statement  The if operator  Logical AND and Logical OR
  • 19. 2 Some Sample Selection Statements within a C++ Program
  • 20. 2 The if Statement ► Any C++ expression can be evaluated as part of an if statement
  • 21. 2 The switch Statement ► When you want to create different outcomes depending on specific values of a variable, you can use a series of ifs shown in the program statement in Figure 2-14 ► As an alternative to the long string of ifs shown in Figure 2-14, you can use the switch statement ► The switch can contain any number of cases in any order
  • 22. 2 The if Operator ► Another alternative to the if statement involves the if operator (also called the conditional operator), which is represented by a question mark (?) ► E.g. ► cout<<(driveAge<26)?”The driver is under 26”:”The driver is at least 26”; ► The if operator provides a concise way to express two alternatives ► The conditional operator is an example of a ternary operator, one that takes three operands instead of just one or two
  • 23. 2 Logical AND and Logical OR ► In some programming situations, two or more conditions must be true to initiate an action ► Figure 2-16 works correctly using a nested if— that is, one if statement within another if statement ► If numVisits is not greater than 5, the statement is finished—the second comparison does not even take place ► Alternatively, a logical AND (&&) can be used, as shown in Figure 2-17
  • 24. 2 Logical AND and Logical OR
  • 25. 2 Using the Logical OR ► In certain programming situations, only one of two alternatives must be true for some action to take place ► A logical OR (||) could also be used ► A logical OR is a compound boolean expression in which either of two conditions must be true for the entire expression to evaluate as true ► Table 2-4 shows how C++ evaluates any expression that uses the || operator
  • 26. 2 Using the Logical OR
  • 27. 2 The while Loop ► Loops provide a mechanism with which to perform statements repeatedly and, just as important, to stop that performance when warranted while (boolean expression) statement; ► In C++, the while statement can be used to loop ► The variable count, shown in the program in Figure 2-21, is often called a loop-control variable, because it is the value of count that controls whether the loop body continues to execute
  • 28. 2 The for Statement ► The for statement represents an alternative to the while statement ► It is most often used in a definite loop, or a loop that must execute a definite number of times ► It takes the form: for (initialize; evaluate; alter) statement;