Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 23

Begin with C/C++

Programming Pathshala

A training report

Submitted in partial fulfillment of the requirements for the award of degree


of

B.tech(CSE)

Submitted to

LOVELY PROFESSIONAL UNIVERSITY

PHAGWARA, PUNJAB

From 06/02/2023 to 07/14/2023

SUBMITTED BY

Name of student:
Jiya
Registration
Number:12109727
Signature of
the student:
DECLARATION

I hereby declare that I have completed my six weeks summer training at Programming
pathshala platform from June 2,2023 to July 14,2023 . I have declare that I have worked
full dedication during there 6 weeks of training and my learning outcomes fulfill the
requirements of training for the award of degree of B.tech. CSE , Lovely Proffesional
University, Phagwara.

Name of Student –Jiya

Registration no: 12109727


ACKNOWLEDGEMENT

I would like to express my gratitude towards my University as well as Programming pathshala for
providing me the golden opportunity to do this wonderful summer training regarding C++,which also
helped me in doinga lot of homework and learning.As a result, I came to know about so many new
things. So, I am really thank full to them.

Moreover I would like to thank my friends who helped me a lot whenever I got stuck in some problem
related to my course. I am really thankfull to have such a good support of them as they always have
my back whenever I need.

Also,I would like to mention the support system and consideration of my parents who have always
been there in my life to make me choose right thing and oppose the wrong. Without them I could
never had learned and became a person who I am now.

I have taken efforts in this project. However, it would not have been possible without the kind
support and help of many individuals and organizations. I would like to extend my sincere thanks to
all of them.
SUMMER TRAINING CERTIFICATE BY
Programming Pathshala
S. No. Title

1 Introduction

2 Technology Learnt

3 Reason for choosing C++


4 Learning Outcome

5 Bibliography
INTRODUCTION

C++, as we all know is an extension to C language and was developed by Bjarne


stroustrup at bell labs. C++ is an intermediate level language, as it comprises a
confirmation of both high level and low level language features. C++ is a statically typed,
free form, multiparadigm, compiled general-purpose language.
C++ is an Object Oriented Programming language but is not purely Object Oriented. Its
features like Friend and Virtual, violate some of the very important OOPS features,
rendering this language unworthy of being called completely Object Oriented. Its a
middle level language.

• Benefits of C++ over C Language


The major difference being OOPS concept, C++ is an object oriented language whereas
C language is a procedural language. Apart form this there are many other features of
C++ which gives this language an upper hand on C language.
Following features of C++ makes it a stronger language than C,

1. There is Stronger Type Checking in C++.


2. All the OOPS features in C++ like Abstraction, Encapsulation, Inheritance
etc makes it more worthy and useful for programmers.
3. C++ supports and allows user defined operators (i.e Operator Overloading)
and function overloading is also supported in it.
4. Exception Handling is there in C++.
5. The Concept of Virtual functions and also Constructors and Destructors
for Objects.
6. Inline Functions in C++ instead of Macros in C language. Inline functions
make complete function body act like Macro, safely.
7. Variables can be declared anywhere in the program in C++, but must be
declared before they are used.

Object Oriented programming is a programming style that is associated with the


concept of Class, Objects and various other concepts revolving around these two, like
Inheritance, Polymorphism, Abstraction, Encapsulation etc.
TECHNOLOGY LEARNT
Object oriented programming – As the name suggests uses objects in programming. Object oriented
programming aims to implement real world entities like inheritance, hiding, polymorphism etc in
programming. The main aim of OOP is to bind together the data and the functions that operate on
them so that no other part of code can access this data except that function.

Object: Objects are basic run-time entities in an object-oriented system, objects are instances of a class
that are user defined data types.

E.g.:

class person

char name

[2]; int id;

public:

void getdetails ()

{}

};

int main ()
{

person p1; //p1 is an object

Objects take up space in memory and have an associated address like a record in pascal or structure or
union in C.

When a program is executed the objects interact by sending messages to one another.

Each object contains data and code to manipulate the data. Objects can interact without having to
know details of each other's data or code, it is sufficient to know the type of message accepted
and type of response returned by the objects.

Class: Class is a blueprint of data and functions or methods. Class does not take any
space. syntax for class:

class class_name

private:

//data members and member functions declarations public:

//data members and member functions declarations protected:

//data members and member functions declarations

};
Class is a user defined data type like structures and unions in C.
By default class variables are private but in case of structure it is public. In the above example a
person is a class.

1. Encapsulation
Encapsulation is an OOP technique of wrapping the data and code. In this OOPS concept,
the variables of a class are always hidden from other classes. It can only be accessed using
the methods of their current class. For example - in school, a student cannot exist without a
class..

WHY ENCAPSULATION?

● It is considered good practice to declare your class attributes as private (as often as you can).
Encapsulation ensures better control of your data, because you (or others) can change one part
of the code without affecting other parts
● Increased security of data

2. Abstraction
Data abstraction refers to, providing only needed information to the outside world and hiding
implementation details. For example, consider a class Complex with public functions as getReal() and
getImag(). We may implement the class as an array of size 2 or as two variables. The advantage of
abstractions is, we can change implementation at any point, users of Complex class won’t be
affected as our method interface remains the same. Had our implementation be public, we would
not have been able to change it.

3. Inheritance
Inheritance is the process by which objects of one class acquire the properties of objects of another
class. It supports the concept of hierarchical classification. Inheritance provides reusability. This means
that we can add additional features to an existing class without modifying it.
WHY AND WHEN TO USE INHERITANCE?

● It is useful for code reusability: reuse attributes and methods of an existing class when you create a
new class.
● Multilevel Inheritance and Multiple Inheritance are the two types of Inheritance Classes.

4. Polymorphism
Polymorphism means the ability to take more than one form. An operation may exhibit different
behaviors in different instances. The behavior depends upon the types of data used in the operation.

C++ supports operator overloading and function overloading.

Operator overloading is the process of making an operator to exhibit different behaviors in different
instances is known as operator overloading.

Function overloading is using a single function name to perform different types of tasks.
polymorphism is extensively used in implementing inheritance.

For example, think of a base class called Animal that has a method called animalSound(). Derived
classes of Animals could be Pigs, Cats, Dogs, Birds - And they also have their own implementation of
an animal sound (the pig oinks, and the cat meows, etc.
REASON FOR CHOOSING C++

All of the above was part of my training during my summer break I specially choose the
C++ from Programming Pathshala for reasons stated below :

• I was interested in Problem Solving and Algorithms since my first semester.


• C++ is a thing you need to know no matter in which language do you code.
• One need to learn how to make codes of a real life problem he/she is facing.
• It had video lectures of all the topics from which one can easily learn. I prefer
learning from video rather than books and notes. I know books and notes and thesis
have their own significance but still video lecture or face to face lectures make it
easy to understand faster as we are involved Practically.
• It had 200+ coding problems with video explaind solutions.
• It had track based learning and weekly assesment to test my skills.
• It contained a lot of knowledge for such a resonable price.
• This was a life time accessable course which I can use to learn even after my
training whenever I want to revise.
• Along with all these reasons one of the reason was the Programming pathshala
platform whichis offering the course because Programming pathshala is one
of the best platform for
Computer Science Students.

Learning Outcomes
The learning outcomes of this course are:

1. C++ improves from C programming with Object Oriented feature.


2. Learned the syntax and semantics of C++ programming language.
3. Designed the classes for code reuse.
4. Understand data abstraction and encapsulation.
5. Learned how to overload functions and operators in C++.
6. Understand how to apply the major object-oriented concepts to implement
object- oriented programs in C++, encapsulation, inheritance and polymorphism.
7. Understand advanced features of C++ specifically stream I/O, templates and
operator overloading.

C++ in Depth
● Character set
● Identifiers
● Keyword
● Data types

• Character set
The character set of C represents alphabet, digit or any symbol used to represent information.
Types Character Set

Uppercase Alphabets A, B, C, … Y, Z

Lowercase Alphabets a, b, c, … y, z

Digits 0, 1, 2, 3, … 9

Special Symbols ~ ‘ ! @ # % ^ & * ( ) _ - + = | \ { } [ ] : ; " ' <> , . ? /

• Identifiers
Identifiers are the fundamental building blocks of a program

Used to give names to variables, functions, constant, and user defined

data. They are user-defined names and consist of a sequence of letters and

digits

• Keywords
Keywords are those words whose meaning is already defined by Compiler. These keywords cannot be
used as an identifier. Note that keywords are the collection of reserved words and predefined
identifiers. Predefined identifiers are identifiers that are defined by the compiler but can be changed
inmeaning by the user.
For example, you could declare a variable called main inside your main function, initialize it, and then
print out its value (but ONLY do that to verify that you can!). On the other hand, you could not do this
with a variable named else. The difference is that else is a reserved word, while main is "only" a
predefined identifier.
There are a total of 95 reserved words in C++. The reserved words of C++ may be conveniently placed
into several groups. In the first group, we put those that were also present in the C programming
language and have been carried over into C++. There are 32 of these.
There are another 30 reserved words that were not in C, are therefore new to C++ programming
language.

• Data Type
Data type means the type of value a variable will have.
It also defines memory space for a particular variable in the computer.

Type size bytes Minimal range

Char 1 -128 to 127

unsigned char 1 0 to 255

Int 2 or 4 -32768 to 32767

unsigned int 2 or 4 0 to 65535

short int 2 -32768 to 32767

unsigned short int 2 0 to 65535

long int 4 -2147483648 to 2147483647

unsigned long int 4 0 to 4294967295

Float 4 3.4e-38 to 3.4e+38 with 6 digits


of precision
Double 8 1.7e-308 to 1.7e+308 with 15 digits
of precision

long double 10 3.4e-4932 to 1.1e+4932 with 20 digits


of precision

OPERATORS:

• In this TOPIC we will study


– Operators
– Types of Operators
Types of operators are:

1. Arithmetic operator

2.Unary operator

3.Relational operator

4.Logical operator

5.Assignment operator

6.Conditional operator

7.Bitwise operator

8.Special operator

• Arithmetic Operators

These are binary operators i.e. expression requires two operands

E.X a=4, b=9;a+b=13

• Unary Operator

This operator requires only one

operand Those are 1. + ,2. ++,3. - ,4. –

• Relational Operator

It compares two operands depending upon their relation. Expression generates zero(false) or
nonzero(true) value.
Ex.>, <, =, <=,>= etc...

• Logical Operator

It checks the logical relationship between two expressions and the result is zero(false) or
nonzero(true).

Ex. &&, || etc.

• Assignment Operator

They are used to assign the result of an expression on the right side to a variable on the left side.

• Conditional Operator

Conditional operator contains condition followed by two statements. If the condition is true the first
statement is executed otherwise the second statement.

It is also called a ternary operator because it requires three operands.

• Bitwise Operator

A bitwise operator works on each bit of data

Logical Table

a b a&b a|b a^b

0 0 0 0 0

0 1 0 1 1
1 1 1 1 0

1 0 0 1 1

Arrays:
● To declare an array
● To initialize an array
● To pass an array to a function

Introduction

● Arrays
– Collection of related data items of the same data type.
– Static entity – i.e. they remain the same size throughout program execution

● Array
–Group of consecutive memory locations
– Same name and data type
● To refer to an element, specify:
– Array name
– Position number in square brackets ([])

● Format:

array name [position number]


– First element is always at position 0
– E.g. n element array named c:
● c [0], c [1] ...c [n – 1]

Defining Arrays

• When defining arrays, specify:

–Name
–Data Type of array
–Number of elements

data type array Name [number Of Elements];

–Examples:

int students [10];

float my Array [3284];

● Defining multiple arrays of same data type


– Format is like regular variables
– Example:

int b [100], x [27];

● Character arrays

Character arrays can be initialized using string literals

char string1[] = "first";

It is equivalent to

char string1[] = {‘f', ‘i’, 'r', 's', 't', '\0’};

Null character '\0' terminates

strings string1 has 6 elements


STRINGS

● Introduction to string
– Declaration
– Initialization
● Reading and writing strings
– functions of the standard input/output library (stdio.h)
● Processing of strings.
– String Manipulation Functions from the String Handling Library
● Comparing strings
– Determining the length of string

Introduction
● Use of C standard library functions for strings and characters:
– Easy string and character processing
– Programs can process characters, strings, lines of text, and blocks of memory
● These techniques are used to make
– Word processors
– Page layout software
– Typesetting programs

Fundamentals of characters

● Characters
– Building blocks of programs
● Every program is a sequence of meaningfully grouped characters
– Character constant
● An int value represented as a character in single quotes
● 'z' represents the integer value of z (122 ASCII value).
BIBLIOGRAPHY

Programming Pathshala : https://renaissance.programmingpathshala.com/begin-with-c++


Geeksforgeek

You might also like