C++ Report
C++ Report
C++ Report
SUMMER TRAINING
REPORT
BY RUPAL JAIN
(CSE)
INTRODUCTION OF C++
C++ Origins
Low-level languages
Machine, assembly
High-level languages
C, C++, ADA, COBOL, FORTRAN
Object-Oriented-Programming in C++
C++ Terminology
Programs and functions
Basic Input/Output (I/O) with cin and cout
A SIMPLE PROGRAM ON C++
PROGRAMING
return 0;
}
What is C++
APPLICATIONS
1. GAMES
2. GRAPHICS USER INTERFACE
3. WEB BROWSER
4. DATAV= BASE SOFTWARE
5. OPERATING SYSTEM
STANDARD LIBRARY
Standard Libraries
Standard C++ programming is divided into three important parts:
The core library includes the data types, variables and literals, etc.
The standard library includes the set of functions manipulating
strings, files, etc.
The Standard Template Library (STL) includes the set of methods
manipulating a data structure.
USAGE OF C++
Window application
Client-Server application
Device drivers
Embedded firmware etc
PROCESSIVE DIRECTIVE
Preprocessor programs provides preprocessors directives which tell the compiler to preprocess
the source code before compiling. All of these preprocessor directive begins with a ‘#’ (hash)
symbol. This (‘#’) symbol at the beginning of a statement in a C/C++ program indicates that it is
a pre-processor directive. We can place these pre processor directives anywhere in our
program. Examples of some preprocessor directives are: #include , #define, #ifndef etc.
There are 4 main types of preprocessor directives:
Macros : Macros are piece of code in a program which is given some name. Whenever this
name is encountered by the compiler the compiler replaces the name with the actual piece of
code. The ‘#define’ directive is used to define a macro.
File Inclusion: This type of preprocessor directive tells the compiler to include a file in the source
code program. There are two types of files which can be included by the user in the program:
Conditional Compilation : Conditional Compilation directives are type of directives which
helps to compile a specific portion of the program or to skip compilation of some specific part
of the program based on some conditions.
Other directives
COPMPILATION AND RUNNING OF
POGRAM
CONTENTS
Identifier & keyword
Expression
Variables
Data type
Operators
Statements
Conditional(selection)
Iteration( loop)
Jump
Arrays and strings
Function
IDENTIFIER AND KEYWORDS
Identifiers: are names that are used in C++ programs for functions, parameters,
variables, constants, classes, and types. An identifier consists of a sequence of letters,
digits, and underscores that does not begin with a digit. An identifier cannot be a
reserved keyword. The identifier can only be composed of letters, numbers, and the
underscore character. The identifier must begin with a letter or an underscore. It can
not start with a number.C++ gives you a lot of flexibility to name identifiers as you
wish.
Keyword: Keywords are pre-defined or reserved words in a programming language.
Each keyword is meant to perform a specific function in a program. Keywords can’t
be used as variable names. You cannot redefine keywords. C language supports 32
keywords which are given below:
auto double int struct break else long switch case enum
register typedef char extern return union const float short unsigned
continue for signed void default goto size of volatile do if
static while
VARIABLES
Abstract or user defined data type: These data types are defined by user itself.
Several of the basic types can be modified using one or more of these type modifiers
−
signed unsigned short long.
OPERATORS
STATEMENT AS HEADING
Conditional statements, also Iteration Statements: The Jump Statements:Jump
known as selection statements that cause a set of statements are used to alter
statements, are used to make statements to be executed the flow of control
decisions based on a given repeatedly either for a unconditionally. That is, jump
condition. If the condition specific number of times or statements transfer the
evaluates to True, a set of until some condition is program control within a
statements is executed, satisfied are known as function unconditionally. The
otherwise another set of iteration statements.for jump statements defined in
statements is executed. if loop:eg: for(initialization; C++ are break, continue,
statement:eg: if(condition){ condition; incr/decr){ goto and return.break:
//code to be executed } //code to be executed } eg:
if-else while jump-statement;
statement:eg:if(condition){ loop:eg:while(condition){ break;
//code if condition is true //code to be executed } do continue:
}else{ //code if condition is while loop:eg: do{ eg:
false } switch //code to be executed jump-statement;
statement:eg: }while(condition); continue;
switch(expression){ case return:
value1: //code to be eg:
executed; break; statement;
case value2: //code to return;
be executed; break;
ARRAY AND STRING
Array is a container that encapsulates fixed size arrays of the same type. An array is
used to store a collection of data or variables of the same type. In C++, array index
starts from 0. We can store only fixed set of elements in C++ array. There are 2 types
of arrays in C++ programming.
Single Dimensional Array: A one-dimensional array (or single dimension array) is a type
of linear array. Accessing its elements involves a single subscript which can either
represent a row or column index.
eg: Datatype arrayName [sixe] = { initials };
Multidimensional Array: The multidimensional array is also known as rectangular arrays in
C++. It can be two dimensional or three dimensional. The data is stored in tabular form
(row ∗ column) which is also known as matrix.
eg: Datatype array Name [x][y];
Strings: In C++, string is an object of std::string class that represents sequence of
characters. We can perform many operations on strings such as concatenation,
comparison, conversion etc.This string is actually a one-dimensional array of
characters which is terminated by a null character '\0'. Thus a null-terminated string
contains the characters that comprise the string followed by a null.eg: char
greeting[] = "Hello";
FUNCTION
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.
Defining a Function The general form of a C++ function definition is as follows −
return_type
function_name( parameter list )
{body of the function}
Calling a Function
When a program calls a function, program control is transferred to the called function. When it’s return statement is
executed ,it returns program control back to the main program.
Function Arguments
If a function is to use arguments, it must declare variables that accept the values of the arguments. These variables are
called the formal parameters of the function. There are two ways that arguments can be passed to a function −
1. Call by Value This method copies the actual value of an argument into the formal parameter of the function.
2. Call by Reference This method copies the reference of an argument into the formal parameter.
OBJECT ORIENTED PROGRAMMING
Object-Oriented Programming: is a methodology or paradigm to design a program using
classes and objects. It simplifies the software development and maintenance by providing
some concepts:
Object :Any entity that has state and behavior is known as an object. It can be physical and
logical.
Class :Collection of objects is called class. It is a logical entity.
Inheritance :When one object acquires all the properties and behaviours of parent object i.e.
known as inheritance. It provides code reusability.
Polymorphism :When one task is performed by different ways i.e. known as polymorphism. In
C++, we use Function overloading and Function overriding to achieve polymorphism.
CONTD…..