lOMoARcPSD|22341461
Summer training report
Data Structures and algorithm (Rajasthan Technical University)
            Studocu is not sponsored or endorsed by any college or university
              Downloaded by rajat gangwar (rajatgangwar574@gmail.com)
                                   lOMoARcPSD|22341461
             Summer Training Report
                                  On
                 Basic C++ Language
                        Submitted by
        Abhishek Dubey (18EEJCS002)
          Under the Supervision of
               Pratham Pareta
         Pratham Computer Solutions
              Jhalawar - 326001
Department of Computer Science and Engineering
         Engineering College Jhalawar
         Downloaded by rajat gangwar (rajatgangwar574@gmail.com)
                                           lOMoARcPSD|22341461
                                CERTIFICATE
This is to certify that the work contained in this Report entitled “Basics Of
C++” is submitted by Mr.Abhishek Dubey (18EEJCS002) to the Depart-
ment of Computer Science and Engineering, Engineering College Jhalawar,
for the partial fulfillment of the requirements for the workshop in Computer
Science and Engineering.
Mr. Pratham Pareta
Pratham Computers,Jhalawar
                                                                       Pt. Yogesh Sharma
                                                                   HOD, Department of CSE
                                                                 Engineering College Jhalawar
                 Downloaded by rajat gangwar (rajatgangwar574@gmail.com)
                          lOMoARcPSD|22341461
Downloaded by rajat gangwar (rajatgangwar574@gmail.com)
                                         lOMoARcPSD|22341461
Acknowledgment
I find great pleasure in expressing our deep sense of gratitude to-
ward all those who have made it possible for me to complete this
project with success. I would first of all like to thanks to Depart-
ment of computer science and information. I would like to thank
my teacher for all their support and guidance. I would like to thank
Computer Science Department and Pareta Computers who helped
me during the Training for providing me the specific guidance in
Learning whenever needed.
                                         iii
               Downloaded by rajat gangwar (rajatgangwar574@gmail.com)
                                          lOMoARcPSD|22341461
Contents
Acknowledgements                                                                                                                iii
1 Introduction                                                                                                                   3
  1.1 About C++ . . . . . . . . . . . . . . . . . . . . . . . . . . . .                                                          3
  1.2 Application Of C++ . . . . . . . . . . . . . . . . . . . . . . .                                                           3
2 Data Types & Operators                                                                                                         4
  2.1 Data Types & Their Description .                          .   .   .   .   .   .   .   .   .   .   .   .   .   .   .   .    4
      1.Basic Data Types . . . . . . . .                        .   .   .   .   .   .   .   .   .   .   .   .   .   .   .   .    4
      2. Enumerated types . . . . . . .                         .   .   .   .   .   .   .   .   .   .   .   .   .   .   .   .    4
      3. The Type Void . . . . . . . . .                        .   .   .   .   .   .   .   .   .   .   .   .   .   .   .   .    4
      4. Derived Types . . . . . . . . .                        .   .   .   .   .   .   .   .   .   .   .   .   .   .   .   .    4
  2.2 Operators . . . . . . . . . . . . .                       .   .   .   .   .   .   .   .   .   .   .   .   .   .   .   .    5
       1. Relational Operator . . . . . .                       .   .   .   .   .   .   .   .   .   .   .   .   .   .   .   .    5
       2. Arithmetic Operator . . . . .                         .   .   .   .   .   .   .   .   .   .   .   .   .   .   .   .    6
      3. Logical Operator . . . . . . .                         .   .   .   .   .   .   .   .   .   .   .   .   .   .   .   .    6
3 Flow Of Control                                                                                                                7
  3.1 C++ Loop Types . . . . . . . . . . . . . . . . . . . . . . . . .                                                           7
  3.2 C++ decision making statements . . . . . . . . . . . . . . . .                                                             8
4 Functions                                                             10
  4.1 C++ Functions . . . . . . . . . . . . . . . . . . . . . . . . . . 10
5 Classes and Objects                                                   12
  5.1 C++ Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
      C++ Class Definitions . . . . . . . . . . . . . . . . . . . . . . 12
      Define C++ Objects . . . . . . . . . . . . . . . . . . . . . . . 13
References                                                                                                                      14
References                                                                                                                      14
                                          iv
                Downloaded by rajat gangwar (rajatgangwar574@gmail.com)
                                         lOMoARcPSD|22341461
List of Figures
 3.1   Control Flow Diagram Of Loop . . . . . . . . . . . . . . . . .      7
 3.2   Control Flow Diagram Of If - else . . . . . . . . . . . . . . . .   8
               Downloaded by rajat gangwar (rajatgangwar574@gmail.com)
                                         lOMoARcPSD|22341461
List of Tables
 2.1   Rational Operators . . . . . . . . . . . . . . . . . . . . . . . .   5
 2.2   Arithmetic Operator . . . . . . . . . . . . . . . . . . . . . . .    6
 2.3   Logical Operator . . . . . . . . . . . . . . . . . . . . . . . . .   6
 3.1   Loop Statements . . . . . . . . . . . . . . . . . . . . . . . . .    8
 3.2   Decision Making statements . . . . . . . . . . . . . . . . . . .     9
               Downloaded by rajat gangwar (rajatgangwar574@gmail.com)
                                         lOMoARcPSD|22341461
Chapter 1
Introduction
1.1    About C++
 1. C++ is a compiled, object oriented language.
 2. It is the “successor ” to c, a procedural language.
      • The “c++” is called the successor operator in C++.
      • C++ was developed in the early 1980’s by Bjarne Stroustrup of
        ATT Bell Labs.
 3. C++ is a statically typed, compiled, case-sensitive , free-form program-
    ming language that support procedural, object oriented, and generic
    programming(graphs, arrays).
1.2    Application Of C++
 1. C++ is a versatile (flexible) language for handling very large programs.
    It is suitable for virtually and programming task including development
    of editors, compilers, database, communication systems and any com-
    plex real-life application systems.
 2. Since C++ allows us to create hierarchy-related object, we can build
    special object-oriented libraries which can be used later by many pro-
    grammers.
               Downloaded by rajat gangwar (rajatgangwar574@gmail.com)
                                           lOMoARcPSD|22341461
Chapter 2
Data Types & Operators
2.1     Data Types & Their Description
1.Basic Data Types
They are arithmetic types and are further classified into:
        • Integer Type
        • Floating type
2. Enumerated types
They are again arithmetic types and they are used to define variables that
can only assign certain discrete integer values throughout the program.
3. The Type Void
The type specifier void indicates that no value is available.
4. Derived Types
They include
        • Pointer types
        • Array types
        • Structure types
        • Union types
        • Function types
                 Downloaded by rajat gangwar (rajatgangwar574@gmail.com)
                                    lOMoARcPSD|22341461
2.2   Operators
1. Relational Operator
                 Table 2.1: Rational Operators
          Downloaded by rajat gangwar (rajatgangwar574@gmail.com)
                                     lOMoARcPSD|22341461
2. Arithmetic Operator
                 Table 2.2: Arithmetic Operator
3. Logical Operator
                   Table 2.3: Logical Operator
           Downloaded by rajat gangwar (rajatgangwar574@gmail.com)
                                           lOMoARcPSD|22341461
Chapter 3
Flow Of Control
3.1     C++ Loop Types
There may be a situation, when you need to execute a block of code several
number of times. In general, statements are executed sequentially: The first
statement in a function is executed first, followed by the second, and so on.
A loop statement allows us to execute a statement or group of statements
multiple times and following is the general from of a loop statement in most
of the programming languages
                Figure 3.1: Control Flow Diagram Of Loop
                 Downloaded by rajat gangwar (rajatgangwar574@gmail.com)
                                           lOMoARcPSD|22341461
    C++ programming language provides the following type of loops to han-
dle looping requirements.
                         Table 3.1: Loop Statements
3.2     C++ decision making statements
Following is the general form of a typical decision making structure found in
most of the programming languages
               Figure 3.2: Control Flow Diagram Of If - else
                 Downloaded by rajat gangwar (rajatgangwar574@gmail.com)
                                         lOMoARcPSD|22341461
    C++ programming language provides following types of decision making
statements
                 Table 3.2: Decision Making statements
               Downloaded by rajat gangwar (rajatgangwar574@gmail.com)
                                           lOMoARcPSD|22341461
Chapter 4
Functions
4.1     C++ Functions
A function is a group of statements that together perform a task. Every
C++ program has at least one function, which is main(), and all the most
trivial programs can define additional functions.
    You can divide up your code into separate functions. How you divide up
your code among different functions is up to you, but logically the division
usually is such that each function performs a specific task.
    A function declaration tells the compiler about a function’s name, return
type, and parameters. A function definition provides the actual body of the
function.
   The general form of a C++ function definition is as follows
                                          10
                 Downloaded by rajat gangwar (rajatgangwar574@gmail.com)
                                          lOMoARcPSD|22341461
   A C++ function definition consists of a function header and a function
body. Here are all the parts of a function
   • Return Type : A function may return a value. The returnType is the
     data type of the value the function returns. Some functions perform
     the desired operations without returning a value. In this case, the
     returnType is the keyword void.
   • Function Name : This is the actual name of the function. The function
     name and the parameter list together constitute the function signature.
   • Parameters : A parameter is like a placeholder. When a function is
     invoked, you pass a value to the parameter. This value is referred to as
     actual parameter or argument. The parameter list refers to the type,
     order, and number of the parameters of a function. Parameters are
     optional; that is, a function may contain no parameters.
   • Function Body : The function body contains a collection of statements
     that define what the function does.
   Example :
                                         11
                Downloaded by rajat gangwar (rajatgangwar574@gmail.com)
                                           lOMoARcPSD|22341461
Chapter 5
Classes and Objects
5.1       C++ Classes
The main purpose of C++ programming is to add object orientation to
the C programming language and classes are the central feature of C++
that supports object-oriented programming and are often called user-defined
types.
    A class is used to specify the form of an object and it combines data rep-
resentation and methods for manipulating that data into one neat package.
The data and functions within a class are called members of the class.
C++ Class Definitions
When you define a class, you define a blueprint for a data type. This doesn’t
actually define any data, but it does define what the class name means, that
is, what an object of the class will consist of and what operations can be
performed on such an object.
    A class definition starts with the keyword class followed by the class
name; and the class body, enclosed by a pair of curly braces. A class
definition must be followed either by a semicolon or a list of declarations.
                                          12
                 Downloaded by rajat gangwar (rajatgangwar574@gmail.com)
                                           lOMoARcPSD|22341461
    For example, we defined the Box data type using the keyword class as
follows
    The keyword public determines the access attributes of the members of
the class that follows it. A public member can be accessed from outside the
class anywhere within the scope of the class object. You can also specify
the members of a class as private or protected which we will discuss in a
sub-section.
Define C++ Objects
A class provides the blueprints for objects, so basically an object is created
from a class. We declare objects of a class with exactly the same sort of
declaration that we declare variables of basic types. Following statements
declare two objects of class Box
  Both of the objects Box1 and Box2 will have their own copy of data
members.
                                          13
                 Downloaded by rajat gangwar (rajatgangwar574@gmail.com)
                                        lOMoARcPSD|22341461
References
[1] https://www.tutorialspoint.com/cplusplus/index.htm
[2] www.w3schools.com
[3] The C++ Programming Language by Bjarne Stroustrup
                                       14
              Downloaded by rajat gangwar (rajatgangwar574@gmail.com)