You are on page 1of 26

WELCOME

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

 A computer programmer is a skilled professional who codes, tests,


debugs, and maintains the comprehensive instructions known as
computer programs that devices should follow to execute their
functions.
 Computer programmers also conceptualize, design, and test logical
structures to solve computer issues. Programmers make use of
specific computer languages like C, C++, Java, PHP, .NET, etc. to
convert the program designs developed by software developers or
system architects into instructions that the computer could follow.
They often refer to code libraries for simplifying their coding, and
might build or make use of computer-aided software tools to
automate the coding.
contd…

A computer programmer is also referred to as a programmer, coder,


developer, or software engineer. Also, the term is often used to refer to a
stand-alone software developer, mobile applications developer, Web
developer, software analyst, embedded firmware developer, and so on.
A SIMPLE PROGRAM
#include <iostream.h>
int main() {
cout << “Hello world!”;

return 0;
}
What is C++

 C++ is a high-level programming language developed by Bjarne Stroustrup at


Bell Labs. C++ adds object-oriented features to its predecessor, C. C++ is one of
the most popular programming language for graphical applications, such as
those that run in Windows and Macintosh environments.
 C++ is a sensitive language.
ORIGIN OF C++

 C++ is a programming language developed at AT&T Bell Laboratories


by Bjarne Stroustrup in the early 1980's. The language was designed
with the intent of merging the efficiency and conciseness of C with the
object-oriented programming features of SIMULA-67. Since its creation,
the language has evolved rapidly and several new features have been
added since its initial release in 1985. The language also promises to
provide support for several other useful mechanisms such as
parameterized types and exception handling in the near future. A
formal ANSI-C++ committee (X3J16) has since been established to help
develop an accurate and reliable standard for the language which
should eliminate most, if not all, ambiguities in the C++ compilers and
translators of today. It is expected that this committee will adopt most
of the rules present in the ANSI base document The Annotated C++
Reference Manual as written by Ellis and Stroustrup .
Structure of simple program

1 #include <iostream> Hello World!


2 using namespace std;
3
4 // main() is where program
5 execution begins.
6 int main()
7 {
cout << "Hello World"; //
prints Hello World
return 0;}
Why learn C++

 C++ is known to be a very powerful language. C++ allows you to have


a lot of control as to how you use computer resources, so in the right
hands its speed and ability to cheaply use resources should be able to
surpass other languages. Thanks to C++'s performance, it is often used
to develop game engines, games, and desktop apps. Many AAA title
video games are built with 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++

 By the help of C++ programming language, we can develop


different types of secured and robust applications:

 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

 A variable is a name of memory location. It is used to store data. Its


value can be changed and it can be reused many times.It is a way
to represent memory location through symbol so that it can be
easily identified.
 Let's see the syntax to declare a variable:
 type variable list;
 The example of declaring variable is given below:
 int x; float y; char z;
DATA TYPE
 Data Types: A data type specifies the type of data that a variable can store such as
integer, floating, character etc.
 Data types in C++ is mainly divided into two types:
 Primitive Data Types: These data types are built-in or predefined data types. Primitive
data types available in C++ are:

 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…..

 Abstraction :Hiding internal details and showing functionality is


known as abstraction. In C++, we use abstract class and interface to
achieve abstraction.
 Encapsulation: Binding (or wrapping) code and data together into
a single unit is known as encapsulation.
 Exception Handling :Exception handling is a feature of OOP, to
handle unresolved exceptions or errors produced at runtime.
CLASSES AND OBJECT
 Classes and Object C++ is an object-oriented language, program is designed using
objects and classes in C++.
C++ Object
In C++, Object is a real world entity. In other words, object is an entity that has state and
behavior. Here, state means data and behavior means functionality. It is a runtime
entity, it is created at runtime. It is an instance of a class. All the members of the class
can be accessed through object.
eg: Student s1; //creating an object of class Student
C++ Class
In C++, object is a group of similar objects. It is a template from which objects are
created. It can have fields, methods, constructors etc.
eg: class Student
{
public:
int id; //field or data member
float salary; //field or data member
String name;//field or data member
}
THANK YOU

You might also like