C++ Test Notes Lesson 1

You might also like

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

TEST NOTES LESSON 1

INTRODUCTION TO OOPS
2 MARKS QUESTION/ANSWERS:

Q.1 DEFINE OOPS:

ANS: OOP stands for Object-Oriented Programming. Procedural programming


is about writing procedures or functions that perform operations on the data,
while object-oriented programming is about creating objects that contain both
data and functions.

Q.1 ਓਪਸ ਨੂੰ ਪਰਿਭਾਸ਼ਿਤ ਕਰੋ:

ANS: OOP ਦਾ ਅਰਥ ਹੈ ਆਬਜੈਕਟ-ਓਰੀਐਂਟਡ ਪ੍ਰੋਗਰਾਮਿੰ ਗ। ਪ੍ਰੋਸੀਜਰਲ ਪ੍ਰੋਗ੍ਰਾਮਿੰ ਗ ਉਹਨਾਂ

ਪ੍ਰਕਿਰਿਆਵਾਂ ਜਾਂ ਫੰ ਕਸ਼ਨਾਂ ਨੂੰ ਲਿਖਣ ਬਾਰੇ ਹੈ ਜੋ ਡੇਟਾ 'ਤੇ ਸੰ ਚਾਲਨ ਕਰਦੇ ਹਨ, ਜਦੋਂ ਕਿ

ਆਬਜੈਕਟ-ਓਰੀਐਂਟਡ ਪ੍ਰੋਗਰਾਮਿੰ ਗ ਉਹ ਵਸਤੂਆਂ ਬਣਾਉਣ ਬਾਰੇ ਹੈ ਜਿਸ ਵਿੱ ਚ ਡੇਟਾ ਅਤੇ

ਫੰ ਕਸ਼ਨ ਦੋਵੇਂ ਸ਼ਾਮਲ ਹੁੰ ਦੇ ਹਨ।

Q.2 ADVANTAGES OF OOPS?

ANS: Object-oriented programming has several advantages

 OOP is faster and easier to execute

 OOP provides a clear structure for the programs


 OOP helps to keep the C++ code DRY "Don't Repeat Yourself", and
makes the code easier to maintain, modify and debug
 OOP makes it possible to create full reusable applications with less code
and shorter development time

Q.2 ਓਪਸ ਦੇ ਫਾਇਦੇ?

ANS: ਆਬਜੈਕਟ-ਅਧਾਰਿਤ ਪ੍ਰੋਗਰਾਮਿੰ ਗ ਦੇ ਕਈ ਫਾਇਦੇ ਹਨ

• OOP ਚਲਾਉਣਾ ਤੇਜ਼ ਅਤੇ ਆਸਾਨ ਹੈ


• OOP ਪ੍ਰੋਗਰਾਮਾਂ ਲਈ ਇੱ ਕ ਸਪੱ ਸ਼ਟ ਢਾਂਚਾ ਪ੍ਰਦਾਨ ਕਰਦਾ ਹੈ

• OOP C++ ਕੋਡ ਨੂੰ DRY "ਆਪਣੇ ਆਪ ਨੂੰ ਨਾ ਦੁਹਰਾਓ" ਰੱ ਖਣ ਵਿੱ ਚ ਮਦਦ ਕਰਦਾ ਹੈ, ਅਤੇ
ਕੋਡ ਨੂੰ ਬਣਾਈ ਰੱ ਖਣ, ਸੋਧਣ ਅਤੇ ਡੀਬੱ ਗ ਕਰਨਾ ਆਸਾਨ ਬਣਾਉਂਦਾ ਹੈ।

• OOP ਘੱ ਟ ਕੋਡ ਅਤੇ ਘੱ ਟ ਵਿਕਾਸ ਸਮੇਂ ਦੇ ਨਾਲ ਪੂਰੀ ਮੁੜ ਵਰਤੋਂ ਯੋਗ ਐਪਲੀਕੇਸ਼ਨ ਬਣਾਉਣਾ
ਸੰ ਭਵ ਬਣਾਉਂਦਾ ਹੈ

Q.3 What is C++?

ANS: C++ is a cross-platform language that can be used to create high-


performance applications.

C++ was developed by Bjarne Stroustrup, as an extension to the C language.

C++ gives programmers a high level of control over system resources and
memory.

The language was updated 4 major times in 2011, 2014, 2017, and 2020 to C+
+11, C++14, C++17, C++20.

Q.3 C++ ਕੀ ਹੈ?

ANS: C++ ਇੱ ਕ ਕਰਾਸ-ਪਲੇਟਫਾਰਮ ਭਾਸ਼ਾ ਹੈ ਜਿਸਦੀ ਵਰਤੋਂ ਉੱਚ-ਪ੍ਰਦਰਸ਼ਨ ਵਾਲੀਆਂ


ਐਪਲੀਕੇਸ਼ਨਾਂ ਬਣਾਉਣ ਲਈ ਕੀਤੀ ਜਾ ਸਕਦੀ ਹੈ।

C++ ਨੂੰ Bjarne Stroustrup ਦੁਆਰਾ C ਭਾਸ਼ਾ ਦੇ ਐਕਸਟੈਂਸ਼ਨ ਵਜੋਂ ਵਿਕਸਤ ਕੀਤਾ ਗਿਆ ਸੀ।

C++ ਪ੍ਰੋਗਰਾਮਰਾਂ ਨੂੰ ਸਿਸਟਮ ਸਰੋਤਾਂ ਅਤੇ ਮੈਮੋਰੀ ਉੱਤੇ ਉੱਚ ਪੱ ਧਰ ਦਾ ਨਿਯੰ ਤਰਣ ਦਿੰ ਦਾ ਹੈ।

ਭਾਸ਼ਾ ਨੂੰ 2011, 2014, 2017, ਅਤੇ 2020 ਵਿੱ ਚ C++11, C++14, C++17, C++20 ਵਿੱ ਚ 4 ਮੁੱ ਖ
ਵਾਰ ਅੱ ਪਡੇਟ ਕੀਤਾ ਗਿਆ ਸੀ।

Q.4 Why Use C++?

ANS: C++ is one of the world's most popular programming languages.


C++ can be found in today's operating systems, Graphical User Interfaces, and
embedded systems.

C++ is an object-oriented programming language which gives a clear structure


to programs and allows code to be reused, lowering development costs.

C++ is portable and can be used to develop applications that can be adapted to
multiple platforms.

C++ is fun and easy to learn!

As C++ is close to C, C# and Java, it makes it easy for programmers to switch to


C++ or vice versa.

Q.4 C++ ਦੀ ਵਰਤੋਂ ਕਿਉਂ ਕਰੀਏ?

ANS: C++ ਦੁਨੀਆ ਦੀਆਂ ਸਭ ਤੋਂ ਪ੍ਰਸਿੱ ਧ ਪ੍ਰੋਗਰਾਮਿੰ ਗ ਭਾਸ਼ਾਵਾਂ ਵਿੱ ਚੋਂ ਇੱ ਕ ਹੈ।

C++ ਅੱ ਜ ਦੇ ਓਪਰੇਟਿੰ ਗ ਸਿਸਟਮਾਂ, ਗ੍ਰਾਫਿਕਲ ਯੂਜ਼ਰ ਇੰ ਟਰਫੇਸ, ਅਤੇ ਏਮਬੈਡਡ ਸਿਸਟਮਾਂ ਵਿੱ ਚ
ਪਾਇਆ ਜਾ ਸਕਦਾ ਹੈ।

C++ ਇੱ ਕ ਆਬਜੈਕਟ-ਓਰੀਐਂਟਿਡ ਪ੍ਰੋਗ੍ਰਾਮਿੰ ਗ ਭਾਸ਼ਾ ਹੈ ਜੋ ਪ੍ਰੋਗਰਾਮਾਂ ਨੂੰ ਇੱ ਕ ਸਪਸ਼ਟ ਢਾਂਚਾ


ਦਿੰ ਦੀ ਹੈ ਅਤੇ ਕੋਡ ਨੂੰ ਦੁਬਾਰਾ ਵਰਤਣ ਦੀ ਇਜਾਜ਼ਤ ਦਿੰ ਦੀ ਹੈ, ਵਿਕਾਸ ਲਾਗਤਾਂ ਨੂੰ ਘਟਾਉਂਦੀ ਹੈ।

C++ ਪੋਰਟੇਬਲ ਹੈ ਅਤੇ ਇਸਦੀ ਵਰਤੋਂ ਉਹਨਾਂ ਐਪਲੀਕੇਸ਼ਨਾਂ ਨੂੰ ਵਿਕਸਤ ਕਰਨ ਲਈ ਕੀਤੀ ਜਾ
ਸਕਦੀ ਹੈ ਜਿਨ੍ਹਾਂ ਨੂੰ ਕਈ ਪਲੇਟਫਾਰਮਾਂ ਲਈ ਅਨੁਕੂਲ ਬਣਾਇਆ ਜਾ ਸਕਦਾ ਹੈ।

C++ ਮਜ਼ੇਦਾਰ ਅਤੇ ਸਿੱ ਖਣਾ ਆਸਾਨ ਹੈ!

ਜਿਵੇਂ ਕਿ C++ C, C# ਅਤੇ Java ਦੇ ਨੇ ੜੇ ਹੈ, ਇਹ ਪ੍ਰੋਗਰਾਮਰਾਂ ਲਈ C++ ਜਾਂ ਇਸਦੇ ਉਲਟ
ਬਦਲਣਾ ਆਸਾਨ ਬਣਾਉਂਦਾ ਹੈ।

Q.5 Difference between C and C++? (2 MARKS/ 10 MARKS)

ANS:
C C++

C was developed by Dennis Ritchie


C++ was developed by Bjarne
between the year 1969 and 1973 at
Stroustrup in 1979.
AT&T Bell Labs.
C C++

C does no support polymorphism, C++


encapsulation, and inheritance supports polymorphism, encapsulati
which means that C does not on, and inheritance because it is an
support object oriented object oriented programming
programming. language.

C is (mostly) a subset of C++. C++ is (mostly) a superset of C.

Number of keywords in C: Number of keywords in C++:


* C90: 32 * C++98: 63
* C99: 37 * C++11: 73
* C11: 44 * C++17: 73
* C23: 59 * C++20: 81

C++ is known as hybrid language


For the development of code, C because C++ supports
supports procedural programming. both procedural and object oriented
programming paradigms.

Data and functions are separated in


Data and functions are encapsulated
C because it is a procedural
together in form of an object in C++.
programming language.

Data is hidden by the Encapsulation


C does not support information
to ensure that data structures and
hiding.
operators are used as intended.

Built-in & user-defined data types is


Built-in data types is supported in C.
supported in C++.

C is a function driven language C++ is an object driven language


because C is a procedural because it is an object oriented
programming language. programming.

Function and operator overloading is Function and operator overloading is


not supported in C. supported by C++.

C is a function-driven language. C++ is an object-driven language


C C++

Functions in C are not defined inside Functions can be used inside a


structures. structure in C++.

Namespace features are not present Namespace is used by C++, which


inside the C. avoid name collisions.

Standard IO header is stdio.h. Standard IO header is iostream.h.

Reference variables are not Reference variables are supported by


supported by C. C++.

Virtual and friend functions are not Virtual and friend functions are
supported by C. supported by C++.

C does not support inheritance. C++ supports inheritance.

Instead of focusing on data, C C++ focuses on data instead of


focuses on method or process. focusing on method or procedure.

C
C++ provides new operator for
provides malloc() and calloc() functio
memory allocation and delete
ns for dynamic memory allocation,
operator for memory de-allocation.
and free() for memory de-allocation.

Direct support for exception Exception handling is supported by


handling is not supported by C. C++.

scanf() and printf() functions are cin and cout are used
used for input/output in C. for input/output in C++.

C structures don’t have access C ++ structures have access


modifiers. modifiers.

C follows the top-down approach C++ follows the Bottom-up approach

There is no strict type checking in C Strict type checking in done in C++.


programming language. So many programs that run well in C
compiler will result in many warnings
C C++

and errors under C++ compiler.

C does not support overloading C++ does support overloading

Type punning with unions is


Type punning with unions is allows
undefined behavior (except in very
(C99 and later)
specific circumstances)

Named initializers may appear out of Named initializers must match the
order data layout of the struct

File extension is “.cpp” or “.c++” or


File extension is “.c”
“.cc” or “.cxx”

Meta-programming: templates
Meta-programming: macros +
(macros are still supported but
_Generic()
discouraged)

There are 32 keywords in the C There are 97 keywords in the C++

C ਨੂੰ ਡੇਨਿਸ ਰਿਚੀ ਦੁਆਰਾ ਸਾਲ 1969 ਅਤੇ C++ ਨੂੰ 1979 ਵਿੱ ਚ ਬਜਾਰਨ ਸਟ੍ਰੌਸਟ੍ਰਪ
1973 ਦੇ ਵਿਚਕਾਰ AT&T ਬੈੱਲ ਲੈਬਜ਼ ਵਿੱ ਚ ਦੁਆਰਾ ਵਿਕਸਤ ਕੀਤਾ ਗਿਆ ਸੀ।
ਵਿਕਸਤ ਕੀਤਾ ਗਿਆ ਸੀ।

C ਕੋਈ ਪੋਲੀਮੋਰਫਿਜ਼ਮ, ਇਨਕੈਪਸੂਲੇਸ਼ਨ,


C++ ਪੋਲੀਮੋਰਫਿਜ਼ਮ, ਇਨਕੈਪਸੂਲੇਸ਼ਨ, ਅਤੇ
ਅਤੇ ਵਿਰਾਸਤ ਦਾ ਸਮਰਥਨ ਨਹੀਂ ਕਰਦਾ ਹੈ
ਵਿਰਾਸਤ ਦਾ ਸਮਰਥਨ ਕਰਦਾ ਹੈ ਕਿਉਂਕਿ
ਜਿਸਦਾ ਮਤਲਬ ਹੈ ਕਿ C ਆਬਜੈਕਟ
ਇਹ ਇੱ ਕ ਆਬਜੈਕਟ ਓਰੀਐਂਟਡ
ਓਰੀਐਂਟਡ ਪ੍ਰੋਗਰਾਮਿੰ ਗ ਦਾ ਸਮਰਥਨ ਨਹੀਂ
ਪ੍ਰੋਗਰਾਮਿੰ ਗ ਭਾਸ਼ਾ ਹੈ।
ਕਰਦਾ ਹੈ।
C C++

C (ਜ਼ਿਆਦਾਤਰ) C++ ਦਾ ਸਬਸੈੱਟ ਹੈ। C++ (ਜ਼ਿਆਦਾਤਰ) C ਦਾ ਇੱ ਕ ਸੁਪਰਸੈੱਟ ਹੈ।


C++ ਵਿੱ ਚ ਕੀਵਰਡਸ ਦੀ ਸੰ ਖਿਆ:
C ਵਿੱ ਚ ਕੀਵਰਡਸ ਦੀ ਸੰ ਖਿਆ: * C++98: 63
* C90: 32 * C++11: 73
* C99: 37 * C++17: 73
* C11: 44 * C++20: 81
* C23: 59 C++ ਨੂੰ ਹਾਈਬ੍ਰਿਡ ਭਾਸ਼ਾ ਵਜੋਂ ਜਾਣਿਆ ਜਾਂਦਾ
ਕੋਡ ਦੇ ਵਿਕਾਸ ਲਈ, C ਵਿਧੀਗਤ
ਹੈ ਕਿਉਂਕਿ C++ ਵਿਧੀਗਤ ਅਤੇ ਆਬਜੈਕਟ
ਪ੍ਰੋਗਰਾਮਿੰ ਗ ਦਾ ਸਮਰਥਨ ਕਰਦਾ ਹੈ।
ਓਰੀਐਂਟਡ ਪ੍ਰੋਗਰਾਮਿੰ ਗ ਪੈਰਾਡਾਈਮ ਦੋਵਾਂ ਦਾ
ਸਮਰਥਨ ਕਰਦਾ ਹੈ।

ਡੇਟਾ ਅਤੇ ਫੰ ਕਸ਼ਨ C++ ਵਿੱ ਚ ਇੱ ਕ ਵਸਤੂ ਦੇ


ਡੇਟਾ ਅਤੇ ਫੰ ਕਸ਼ਨਾਂ ਨੂੰ C ਵਿੱ ਚ ਵੱ ਖ ਕੀਤਾ ਰੂਪ ਵਿੱ ਚ ਇਕੱ ਠੇ ਇਨਕੈਪਸਲੇਟ ਕੀਤੇ ਗਏ
ਗਿਆ ਹੈ ਕਿਉਂਕਿ ਇਹ ਇੱ ਕ ਪ੍ਰਕਿਰਿਆਤਮਕ ਹਨ
ਪ੍ਰੋਗਰਾਮਿੰ ਗ ਭਾਸ਼ਾ ਹੈ। । C++ਡੇਟਾ ਨੂੰ ਐਨਕੈਪਸੂਲੇਸ਼ਨ ਦੁਆਰਾ
C ਜਾਣਕਾਰੀ ਲੁਕਾਉਣ ਦਾ ਸਮਰਥਨ ਨਹੀਂ ਛੁਪਾਇਆ ਜਾਂਦਾ ਹੈ ਤਾਂ ਜੋ ਇਹ ਯਕੀਨੀ
ਕਰਦਾ ਹੈ। ਬਣਾਇਆ ਜਾ ਸਕੇ ਕਿ ਡੇਟਾ ਢਾਂਚੇ ਅਤੇ
ਓਪਰੇਟਰਾਂ ਨੂੰ ਇਰਾਦੇ ਅਨੁਸਾਰ ਵਰਤਿਆ
ਜਾਂਦਾ ਹੈ।

ਬਿਲਟ-ਇਨ ਅਤੇ ਉਪਭੋਗਤਾ ਦੁਆਰਾ

ਬਿਲਟ-ਇਨ ਡਾਟਾ ਕਿਸਮਾਂ C ਵਿੱ ਚ ਪਰਿਭਾਸ਼ਿਤ ਡੇਟਾ ਕਿਸਮਾਂ C++ ਵਿੱ ਚ

ਸਮਰਥਿਤ ਹਨ। । ਸਮਰਥਿਤ ਹਨ


C++ ਇੱ ਕ ਆਬਜੈਕਟ ਨਾਲ ਚੱ ਲਣ ਵਾਲੀ
C ਇੱ ਕ ਫੰ ਕਸ਼ਨ ਸੰ ਚਾਲਿਤ ਭਾਸ਼ਾ ਹੈ ਕਿਉਂਕਿ ਭਾਸ਼ਾ ਹੈ ਕਿਉਂਕਿ ਇਹ ਇੱ ਕ ਆਬਜੈਕਟ
C ਇੱ ਕ ਕਾਰਜਪ੍ਰਣਾਲੀ ਪ੍ਰੋਗਰਾਮਿੰ ਗ ਭਾਸ਼ਾ ਹੈ। ਓਰੀਐਂਟਿਡ ਪ੍ਰੋਗਰਾਮਿੰ ਗ ਹੈ।

ਫੰ ਕਸ਼ਨ ਅਤੇ ਓਪਰੇਟਰ ਓਵਰਲੋਡਿੰ ਗ C++


ਫੰ ਕਸ਼ਨ ਅਤੇ ਓਪਰੇਟਰ ਓਵਰਲੋਡਿੰ ਗ C
ਦੁਆਰਾ ਸਮਰਥਿਤ ਹੈ।
ਵਿੱ ਚ ਸਮਰਥਿਤ ਨਹੀਂ ਹੈ।
C C++

C++ ਇੱ ਕ ਵਸਤੂ-ਸੰ ਚਾਲਿਤ ਭਾਸ਼ਾ ਹੈ


C ਇੱ ਕ ਫੰ ਕਸ਼ਨ ਦੁਆਰਾ ਸੰ ਚਾਲਿਤ ਭਾਸ਼ਾ ਹੈ।
ਫੰ ਕਸ਼ਨਾਂ ਨੂੰ C++ ਵਿੱ ਚ ਇੱ ਕ ਢਾਂਚੇ ਦੇ ਅੰ ਦਰ
C ਵਿੱ ਚ ਫੰ ਕਸ਼ਨਾਂ ਨੂੰ ਢਾਂਚੇ ਦੇ ਅੰ ਦਰ
ਵਰਤਿਆ ਜਾ ਸਕਦਾ ਹੈ।
ਪਰਿਭਾਸ਼ਿਤ ਨਹੀਂ ਕੀਤਾ ਗਿਆ ਹੈ।
ਨੇ ਮਸਪੇਸ C++ ਦੁਆਰਾ ਵਰਤਿਆ ਜਾਂਦਾ ਹੈ,
ਨੇ ਮਸਪੇਸ ਵਿਸ਼ੇਸ਼ਤਾਵਾਂ C ਦੇ ਅੰ ਦਰ ਮੌਜੂਦ
ਜੋ ਨਾਮ ਦੇ ਟਕਰਾਅ ਤੋਂ ਬਚਦੇ ਹਨ।
ਨਹੀਂ ਹਨ।
ਮਿਆਰੀ IO ਸਿਰਲੇਖ iostream.h ਹੈ।
ਸਟੈਂਡਰਡ IO ਹੈਡਰ stdio.h ਹੈ।

ਹਵਾਲਾ ਵੇਰੀਏਬਲ C++ ਦੁਆਰਾ ਸਮਰਥਿਤ


ਹਵਾਲਾ ਵੇਰੀਏਬਲ C ਦੁਆਰਾ ਸਮਰਥਿਤ
ਹਨ।
ਨਹੀਂ ਹਨ।
ਵਰਚੁਅਲ ਅਤੇ ਦੋਸਤ ਫੰ ਕਸ਼ਨ C++ ਦੁਆਰਾ
ਵਰਚੁਅਲ ਅਤੇ ਦੋਸਤ ਫੰ ਕਸ਼ਨ C ਦੁਆਰਾ
ਸਮਰਥਿਤ ਹਨ।
ਸਮਰਥਿਤ ਨਹੀਂ ਹਨ।
C++ ਵਿਰਾਸਤ ਦਾ ਸਮਰਥਨ ਕਰਦਾ ਹੈ
C ਵਿਰਾਸਤ ਦਾ ਸਮਰਥਨ ਨਹੀਂ ਕਰਦਾ ਹੈ। ।
C++ ਵਿਧੀ ਜਾਂ ਵਿਧੀ 'ਤੇ ਧਿਆਨ ਕੇਂਦਰਿਤ
ਡੇਟਾ 'ਤੇ ਫੋਕਸ ਕਰਨ ਦੀ ਬਜਾਏ, C ਵਿਧੀ
ਕਰਨ ਦੀ ਬਜਾਏ ਡੇਟਾ 'ਤੇ ਫੋਕਸ ਕਰਦਾ ਹੈ।
ਜਾਂ ਪ੍ਰਕਿਰਿਆ 'ਤੇ ਧਿਆਨ ਕੇਂਦਰਤ ਕਰਦਾ
ਹੈ।
C++ ਮੈਮੋਰੀ ਅਲੋਕੇਸ਼ਨ ਲਈ ਨਵਾਂ ਆਪਰੇਟਰ
C ਗਤੀਸ਼ੀਲ ਮੈਮੋਰੀ ਵੰ ਡ ਲਈ malloc() ਪ੍ਰਦਾਨ ਕਰਦਾ ਹੈ ਅਤੇ ਮੈਮੋਰੀ ਡੀ-ਅਲੋਕੇਸ਼ਨ
ਅਤੇ calloc() ਫੰ ਕਸ਼ਨ ਪ੍ਰਦਾਨ ਕਰਦਾ ਹੈ, ਲਈ ਡਿਲੀਟ ਆਪਰੇਟਰ ਦਿੰ ਦਾ ਹੈ।
ਅਤੇ ਮੈਮੋਰੀ ਡੀ-ਅਲੋਕੇਸ਼ਨ ਲਈ ਮੁਫਤ ()
ਪ੍ਰਦਾਨ ਕਰਦਾ ਹੈ।
ਅਪਵਾਦ ਹੈਂਡਲਿੰ ਗ C++ ਦੁਆਰਾ ਸਮਰਥਿਤ
ਅਪਵਾਦ ਹੈਂਡਲਿੰ ਗ ਲਈ ਸਿੱ ਧਾ ਸਮਰਥਨ C
ਹੈ।
ਦੁਆਰਾ ਸਮਰਥਿਤ ਨਹੀਂ ਹੈ।
C C++

C++ ਵਿੱ ਚ ਇਨਪੁਟ/ਆਊਟਪੁੱ ਟ ਲਈ cin


scanf() ਅਤੇ printf() ਫੰ ਕਸ਼ਨ C ਵਿੱ ਚ
ਅਤੇ cout ਦੀ ਵਰਤੋਂ ਕੀਤੀ ਜਾਂਦੀ ਹੈ।
ਇਨਪੁਟ/ਆਊਟਪੁੱ ਟ ਲਈ ਵਰਤੇ ਜਾਂਦੇ
ਹਨ।

C++ ਢਾਂਚਿਆਂ ਵਿੱ ਚ ਐਕਸੈਸ ਮੋਡੀਫਾਇਰ ਹੁੰ ਦੇ


C ਢਾਂਚਿਆਂ ਵਿੱ ਚ ਐਕਸੈਸ ਮੋਡੀਫਾਇਰ ਨਹੀਂ
ਹਨ।
ਹਨ।

C ਉੱਪਰ-ਡਾਊਨ ਪਹੁੰ ਚ ਦੀ ਪਾਲਣਾ ਕਰਦਾ C++ ਥੱ ਲੇ -ਅੱ ਪ ਪਹੁੰ ਚ ਦਾ ਅਨੁਸਰਣ ਕਰਦਾ


ਹੈ ਹੈ

C ਪ੍ਰੋਗਰਾਮਿੰ ਗ ਭਾਸ਼ਾ ਵਿੱ ਚ ਕੋਈ ਸਖਤ । C++ ਵਿੱ ਚ ਸਖਤ ਕਿਸਮ ਦੀ ਜਾਂਚ ਕੀਤੀ
ਕਿਸਮ ਦੀ ਜਾਂਚ ਨਹੀਂ ਹੈ ਗਈ।

C++ ਕੰ ਪਾਈਲਰ ਦੇ ਅਧੀਨ ਬਹੁਤ ਸਾਰੀਆਂ


ਬਹੁਤ ਸਾਰੇ ਪ੍ਰੋਗਰਾਮ ਜੋ C ਕੰ ਪਾਈਲਰ
ਚੇਤਾਵਨੀਆਂ ਅਤੇ ਗਲਤੀਆਂ ਹੋ ਸਕਦੀਆਂ
ਵਿੱ ਚ ਚੰ ਗੀ ਤਰ੍ਹਾਂ ਚੱ ਲਦੇ ਹਨ
ਹਨ।

C ਓਵਰਲੋ ਡਿੰ ਗ ਦਾ ਸਮਰਥਨ ਨਹੀਂ ਕਰਦਾ


C++ ਓਵਰਲੋ ਡਿੰ ਗ ਦਾ ਸਮਰਥਨ ਕਰਦਾ ਹੈ
ਹੈ

ਯੂਨੀਅਨਾਂ ਨਾਲ ਟਾਈਪ ਪੰ ਨਿੰ ਗ ਦੀ ਨਾਮੀ ਸ਼ੁਰੂਆਤੀ ਕ੍ਰਮ ਦੇ ਬਾਹਰ ਦਿਖਾਈ ਦੇ


ਆਗਿਆ ਹੈ (C99 ਅਤੇ ਬਾਅਦ ਵਿੱ ਚ) ਸਕਦੇ ਹਨ ਨਾਮ ਦੇ ਸ਼ੁਰੂਆਤੀ ਸਟਰਕਚਰ
ਯੂਨੀਅਨਾਂ ਨਾਲ ਟਾਈਪ ਪੰ ਨਿੰ ਗ ਇੱ ਕ ਦੇ ਡੇਟਾ ਲੇ ਆਉਟ ਨਾਲ ਮੇਲ ਖਾਂਦੇ ਹੋਣੇ
C C++

ਚਾਹੀਦੇ ਹਨ
ਪਰਿਭਾਸ਼ਿਤ ਵਿਵਹਾਰ ਹੈ (ਬਹੁਤ ਖਾਸ
ਸਥਿਤੀਆਂ ਨੂੰ ਛੱ ਡ ਕੇ)

ਫਾਈਲ ਐਕਸਟੈਂਸ਼ਨ “.cpp” ਜਾਂ “.c++”


ਫਾਈਲ ਐਕਸਟੈਂਸ਼ਨ “.c” ਹੈ
ਜਾਂ “.cc” ਜਾਂ “.cxx” ਹੈ

ਮੈਟਾ-ਪ੍ਰੋਗਰਾਮਿੰ ਗ: ਟੈਂਪਲੇ ਟਸ (ਮੈਕਰੋ ਅਜੇ


ਮੈਟਾ-ਪ੍ਰੋਗਰਾਮਿੰ ਗ: ਮੈਕਰੋ + _ਜਨਰਿਕ()
ਵੀ ਸਮਰਥਿਤ ਹਨ ਪਰ ਨਿਰਾਸ਼ ਹਨ)

C ਵਿੱ ਚ 32 ਕੀਵਰਡ ਹਨ C++ ਵਿੱ ਚ 97 ਕੀਵਰਡ ਹਨ

Q.6 Similarities between C and C++ ?

ANS:
 Both the languages have a similar syntax.
 Code structure of both the languages are same.
 The compilation of both the languages is similar.
 They share the same basic syntax. Nearly all of C’s operators and keywords
are also present in C++ and do the same thing.
 C++ has a slightly extended grammar than C, but the basic grammar is the
same.
 Basic memory model of both is very close to the hardware.
 Same notions of stack, heap, file-scope and static variables are present in
both the languages.

Q.6 C ਅਤੇ C++ ਵਿਚਕਾਰ ਸਮਾਨਤਾਵਾਂ?

ANS:• ਦੋਨਾਂ ਭਾਸ਼ਾਵਾਂ ਵਿੱ ਚ ਇੱ ਕ ਸਮਾਨ ਸੰ ਟੈਕਸ ਹੈ।

• ਦੋਵਾਂ ਭਾਸ਼ਾਵਾਂ ਦਾ ਕੋਡ ਬਣਤਰ ਇੱ ਕੋ ਜਿਹਾ ਹੈ।


• ਦੋਵਾਂ ਭਾਸ਼ਾਵਾਂ ਦਾ ਸੰ ਕਲਨ ਸਮਾਨ ਹੈ।

• ਉਹ ਇੱ ਕੋ ਜਿਹੇ ਮੂਲ ਸੰ ਟੈਕਸ ਨੂੰ ਸਾਂਝਾ ਕਰਦੇ ਹਨ। C ਦੇ ਲਗਭਗ ਸਾਰੇ ਆਪਰੇਟਰ ਅਤੇ
ਕੀਵਰਡ ਵੀ C++ ਵਿੱ ਚ ਮੌਜੂਦ ਹਨ ਅਤੇ ਉਹੀ ਕੰ ਮ ਕਰਦੇ ਹਨ।

• C++ ਦਾ C ਨਾਲੋਂ ਥੋੜ੍ਹਾ ਜਿਹਾ ਵਿਸਤ੍ਰਿਤ ਵਿਆਕਰਣ ਹੈ, ਪਰ ਮੂਲ ਵਿਆਕਰਣ ਉਹੀ ਹੈ।

• ਦੋਨਾਂ ਦਾ ਬੇਸਿਕ ਮੈਮੋਰੀ ਮਾਡਲ ਹਾਰਡਵੇਅਰ ਦੇ ਬਹੁਤ ਨੇ ੜੇ ਹੈ।

• ਸਟੈਕ, ਹੀਪ, ਫਾਈਲ-ਸਕੋਪ ਅਤੇ ਸਟੈਟਿਕ ਵੇਰੀਏਬਲਾਂ ਦੀਆਂ ਇੱ ਕੋ ਜਿਹੀਆਂ ਧਾਰਨਾਵਾਂ ਦੋਵਾਂ
ਭਾਸ਼ਾਵਾਂ ਵਿੱ ਚ ਮੌਜੂਦ ਹਨ।

Q.7 What are Classes and Objects?

ANS: A class is a template of an object. For example, the animal is a class


& dog is the object of the animal class. It is a user-defined data type. A
class has its own attributes (data members) and behavior (member
functions). The first letter of the class name is always capitalized & use
the class keyword for creating the class.

 class
 Fruit

 The object is an instance of a class. The class itself is just a template


that is not allocated any memory. To use the data and methods
defined in the class, we have to create an object of that class.
 So, a class is a template for objects, and an object is an instance of a
class. In C++, Object is a real world entity, for example, chair, car, pen,
mobile, laptop etc.
 When the individual objects are created, they inherit all the variables
and functions from the class.

Q.7 ਕਲਾਸਾਂ ਅਤੇ ਵਸਤੂਆਂ ਕੀ ਹਨ?


ANS: ਇੱ ਕ ਕਲਾਸ ਇੱ ਕ ਵਸਤੂ ਦਾ ਨਮੂਨਾ ਹੈ। ਉਦਾਹਰਨ ਲਈ, ਜਾਨਵਰ ਇੱ ਕ ਸ਼੍ਰੇਣੀ ਹੈ
ਅਤੇ ਕੁੱ ਤਾ ਜਾਨਵਰਾਂ ਦੀ ਸ਼੍ਰੇਣੀ ਦੀ ਵਸਤੂ ਹੈ। ਇਹ ਉਪਭੋਗਤਾ ਦੁਆਰਾ ਪਰਿਭਾਸ਼ਿਤ ਡੇਟਾ
ਕਿਸਮ ਹੈ। ਇੱ ਕ ਕਲਾਸ ਦੇ ਆਪਣੇ ਗੁਣ (ਡੇਟਾ ਮੈਂਬਰ) ਅਤੇ ਵਿਹਾਰ (ਮੈਂਬਰ ਫੰ ਕਸ਼ਨ)
ਹੁੰ ਦੇ ਹਨ। ਕਲਾਸ ਦੇ ਨਾਮ ਦਾ ਪਹਿਲਾ ਅੱ ਖਰ ਹਮੇਸ਼ਾ ਕੈਪੀਟਲ ਹੁੰ ਦਾ ਹੈ ਅਤੇ ਕਲਾਸ
ਬਣਾਉਣ ਲਈ ਕਲਾਸ ਕੀਵਰਡ ਦੀ ਵਰਤੋਂ ਕਰੋ।

• ਵਸਤੂ ਇੱ ਕ ਕਲਾਸ ਦੀ ਇੱ ਕ ਉਦਾਹਰਣ ਹੈ। ਕਲਾਸ ਆਪਣੇ ਆਪ ਵਿੱ ਚ ਸਿਰਫ ਇੱ ਕ


ਟੈਂਪਲੇਟ ਹੈ ਜਿਸਨੂੰ ਕੋਈ ਮੈਮੋਰੀ ਨਿਰਧਾਰਤ ਨਹੀਂ ਕੀਤੀ ਗਈ ਹੈ। ਕਲਾਸ ਵਿੱ ਚ
ਪਰਿਭਾਸ਼ਿਤ ਡੇਟਾ ਅਤੇ ਵਿਧੀਆਂ ਦੀ ਵਰਤੋਂ ਕਰਨ ਲਈ, ਸਾਨੂੰ ਉਸ ਕਲਾਸ ਦਾ ਇੱ ਕ
ਆਬਜੈਕਟ ਬਣਾਉਣਾ ਹੋਵੇਗਾ।
• ਇਸ ਲਈ, ਇੱ ਕ ਕਲਾਸ ਆਬਜੈਕਟ ਲਈ ਇੱ ਕ ਟੈਂਪਲੇਟ ਹੈ, ਅਤੇ ਇੱ ਕ ਆਬਜੈਕਟ
ਇੱ ਕ ਕਲਾਸ ਦੀ ਇੱ ਕ ਉਦਾਹਰਣ ਹੈ। C++ ਵਿੱ ਚ, ਆਬਜੈਕਟ ਇੱ ਕ ਅਸਲ ਸੰ ਸਾਰ ਦੀ
ਹਸਤੀ ਹੈ, ਉਦਾਹਰਨ ਲਈ, ਕੁਰਸੀ, ਕਾਰ, ਪੈੱਨ, ਮੋਬਾਈਲ, ਲੈਪਟਾਪ ਆਦਿ।
• ਜਦੋਂ ਵਿਅਕਤੀਗਤ ਵਸਤੂਆਂ ਬਣਾਈਆਂ ਜਾਂਦੀਆਂ ਹਨ, ਤਾਂ ਉਹ ਕਲਾਸ ਤੋਂ ਸਾਰੇ
ਵੇਰੀਏਬਲ ਅਤੇ ਫੰ ਕਸ਼ਨਾਂ ਨੂੰ ਪ੍ਰਾਪਤ ਕਰਦੇ ਹਨ।

Q.8 C++ Syntax? (2MARKS/10 MARKS)


OR
DEFINE STRUCTURE OF C++ PROGRAM?
ANS:
Example
#include <iostream>
using namespace std;

int main() {
cout << "Hello World!";
return 0;
}

Explaination:

Line 1: #include <iostream> is a header file library that lets us work with input
and output objects, such as cout (used in line 5). Header files add functionality
to C++ programs.
Line 2: using namespace std means that we can use names for objects and
variables from the standard library.

Don't worry if you don't understand how #include <iostream> and using
namespace std works. Just think of it as something that (almost) always
appears in your program.

Line 3: A blank line. C++ ignores white space. But we use it to make the code
more readable.

Line 4: Another thing that always appear in a C++ program, is int main(). This is
called a function. Any code inside its curly brackets {} will be executed.

Line 5: cout (pronounced "see-out") is an object used together with


the insertion operator (<<) to output/print text. In our example it will output
"Hello World!".

Note: Every C++ statement ends with a semicolon ;.

Note: The body of int main() could also been written as:
int main () { cout << "Hello World! "; return 0; }

Remember: The compiler ignores white spaces. However, multiple lines makes
the code more readable.

Line 6: return 0 ends the main function.

Line 7: Do not forget to add the closing curly bracket }

ਲਾਈਨ 1: #include <iostream> ਇੱ ਕ ਸਿਰਲੇਖ ਫਾਈਲ ਲਾਇਬ੍ਰੇਰੀ ਹੈ ਜੋ ਸਾਨੂੰ ਇਨਪੁਟ

ਅਤੇ ਆਉਟਪੁੱ ਟ ਵਸਤੂਆਂ, ਜਿਵੇਂ ਕਿ cout (ਲਾਈਨ 5 ਵਿੱ ਚ ਵਰਤੀ ਜਾਂਦੀ ਹੈ) ਨਾਲ ਕੰ ਮ

ਕਰਨ ਦਿੰ ਦੀ ਹੈ। ਹੈਡਰ ਫਾਈਲਾਂ C++ ਪ੍ਰੋਗਰਾਮਾਂ ਵਿੱ ਚ ਕਾਰਜਸ਼ੀਲਤਾ ਜੋੜਦੀਆਂ ਹਨ।

ਲਾਈਨ 2: ਨੇ ਮਸਪੇਸ std ਦੀ ਵਰਤੋਂ ਕਰਨ ਦਾ ਮਤਲਬ ਹੈ ਕਿ ਅਸੀਂ ਸਟੈਂਡਰਡ ਲਾਇਬ੍ਰੇਰੀ ਤੋਂ

ਵਸਤੂਆਂ ਅਤੇ ਵੇਰੀਏਬਲਾਂ ਲਈ ਨਾਮ ਵਰਤ ਸਕਦੇ ਹਾਂ।

ਚਿੰ ਤਾ ਨਾ ਕਰੋ ਜੇਕਰ ਤੁਸੀਂ ਇਹ ਨਹੀਂ ਸਮਝਦੇ ਕਿ #include <iostream> ਅਤੇ

namespace std ਦੀ ਵਰਤੋਂ ਕਰਨਾ ਕਿਵੇਂ ਕੰ ਮ ਕਰਦਾ ਹੈ। ਬਸ ਇਸ ਨੂੰ ਕੁਝ ਅਜਿਹਾ ਸਮਝੋ

ਜੋ (ਲਗਭਗ) ਹਮੇਸ਼ਾ ਤੁਹਾਡੇ ਪ੍ਰੋਗਰਾਮ ਵਿੱ ਚ ਦਿਖਾਈ ਦਿੰ ਦਾ ਹੈ।


ਲਾਈਨ 3: ਇੱ ਕ ਖਾਲੀ ਲਾਈਨ। C++ ਵ੍ਹਾਈਟ ਸਪੇਸ ਨੂੰ ਅਣਡਿੱ ਠ ਕਰਦਾ ਹੈ। ਪਰ ਅਸੀਂ

ਇਸਦੀ ਵਰਤੋਂ ਕੋਡ ਨੂੰ ਹੋਰ ਪੜ੍ਹਨਯੋਗ ਬਣਾਉਣ ਲਈ ਕਰਦੇ ਹਾਂ।

ਲਾਈਨ 4: ਇੱ ਕ ਹੋਰ ਚੀਜ਼ ਜੋ ਹਮੇਸ਼ਾ ਇੱ ਕ C++ ਪ੍ਰੋਗਰਾਮ ਵਿੱ ਚ ਦਿਖਾਈ ਦਿੰ ਦੀ ਹੈ, int

main() ਹੈ। ਇਸ ਨੂੰ ਫੰ ਕਸ਼ਨ ਕਿਹਾ ਜਾਂਦਾ ਹੈ। ਇਸਦੇ ਕਰਲੀ ਬਰੈਕਟਾਂ ਦੇ ਅੰ ਦਰ ਕੋਈ ਵੀ

ਕੋਡ {} ਚਲਾਇਆ ਜਾਵੇਗਾ।

ਲਾਈਨ 5: cout (ਉਚਾਰਿਆ "ਸੀ-ਆਊਟ") ਇੱ ਕ ਵਸਤੂ ਹੈ ਜੋ ਸੰ ਮਿਲਨ ਓਪਰੇਟਰ (<<) ਦੇ

ਨਾਲ ਆਉਟਪੁੱ ਟ/ਪ੍ਰਿੰ ਟ ਟੈਕਸਟ ਲਈ ਵਰਤੀ ਜਾਂਦੀ ਹੈ। ਸਾਡੇ ਉਦਾਹਰਣ ਵਿੱ ਚ ਇਹ "ਹੈਲੋ

ਵਰਲਡ!" ਆਉਟਪੁੱ ਟ ਕਰੇਗਾ.

ਨੋ ਟ: ਹਰ C++ ਸਟੇਟਮੈਂਟ ਸੈਮੀਕੋਲਨ ਨਾਲ ਖਤਮ ਹੁੰ ਦੀ ਹੈ;।

ਨੋ ਟ: int main() ਦੇ ਸਰੀਰ ਨੂੰ ਇਸ ਤਰ੍ਹਾਂ ਵੀ ਲਿਖਿਆ ਜਾ ਸਕਦਾ ਹੈ:

int main () { cout << "ਹੈਲੋ ਵਰਲਡ!"; ਵਾਪਸੀ 0; }

ਯਾਦ ਰੱ ਖੋ: ਕੰ ਪਾਈਲਰ ਵਾਈਟ ਸਪੇਸ ਨੂੰ ਨਜ਼ਰਅੰ ਦਾਜ਼ ਕਰਦਾ ਹੈ। ਹਾਲਾਂਕਿ, ਕਈ ਲਾਈਨਾਂ

ਕੋਡ ਨੂੰ ਵਧੇਰੇ ਪੜ੍ਹਨਯੋਗ ਬਣਾਉਂਦੀਆਂ ਹਨ।

ਲਾਈਨ 6: ਵਾਪਸੀ 0 ਮੁੱ ਖ ਫੰ ਕਸ਼ਨ ਨੂੰ ਖਤਮ ਕਰਦਾ ਹੈ।

ਲਾਈਨ 7: ਬੰ ਦ ਕਰਲੀ ਬਰੈਕਟ ਨੂੰ ਜੋੜਨਾ ਨਾ ਭੁੱ ਲੋ }

Q.9 C++ Comments?

ANS: Comments can be used to explain C++ code, and to make it more
readable. It can also be used to prevent execution when testing alternative
code. Comments can be singled-lined or multi-lined

1. Single-line Comments

Single-line comments start with two forward slashes (//).

Any text between // and the end of the line is ignored by the compiler (will not
be executed).
This example uses a single-line comment before a line of code:

Example
// This is a comment
cout << "Hello World!";

This example uses a single-line comment at the end of a line of code:

Example
cout << "Hello World!"; // This is a comment

2. C++ Multi-line Comments

Multi-line comments start with /* and ends with */.

Any text between /* and */ will be ignored by the compiler:

Example
/* The code below will print the words Hello World!
to the screen, and it is amazing */
cout << "Hello World!";

Q.9 C++ ਟਿੱ ਪਣੀਆਂ?

ANS: ਟਿੱ ਪਣੀਆਂ ਦੀ ਵਰਤੋਂ C++ ਕੋਡ ਦੀ ਵਿਆਖਿਆ ਕਰਨ ਅਤੇ ਇਸਨੂੰ ਹੋਰ ਪੜ੍ਹਨਯੋਗ

ਬਣਾਉਣ ਲਈ ਕੀਤੀ ਜਾ ਸਕਦੀ ਹੈ। ਵਿਕਲਪਕ ਕੋਡ ਦੀ ਜਾਂਚ ਕਰਦੇ ਸਮੇਂ ਇਸਦੀ ਵਰਤੋਂ

ਐਗਜ਼ੀਕਿਊਸ਼ਨ ਨੂੰ ਰੋਕਣ ਲਈ ਵੀ ਕੀਤੀ ਜਾ ਸਕਦੀ ਹੈ। ਟਿੱ ਪਣੀਆਂ ਸਿੰ ਗਲ-ਲਾਈਨਡ ਜਾਂ

ਮਲਟੀ-ਲਾਈਨਡ ਹੋ ਸਕਦੀਆਂ ਹਨ

1. ਸਿੰ ਗਲ-ਲਾਈਨ ਟਿੱ ਪਣੀਆਂ

ਸਿੰ ਗਲ-ਲਾਈਨ ਟਿੱ ਪਣੀਆਂ ਦੋ ਫਾਰਵਰਡ ਸਲੈਸ਼ਾਂ (//) ਨਾਲ ਸ਼ੁਰੂ ਹੁੰ ਦੀਆਂ ਹਨ।

// ਅਤੇ ਲਾਈਨ ਦੇ ਅੰ ਤ ਦੇ ਵਿਚਕਾਰ ਕੋਈ ਵੀ ਟੈਕਸਟ ਕੰ ਪਾਈਲਰ ਦੁਆਰਾ ਅਣਡਿੱ ਠ ਕੀਤਾ

ਜਾਂਦਾ ਹੈ (ਐਕਜ਼ੀਕਿਯੂਟ ਨਹੀਂ ਕੀਤਾ ਜਾਵੇਗਾ)।


ਇਹ ਉਦਾਹਰਨ ਕੋਡ ਦੀ ਇੱ ਕ ਲਾਈਨ ਤੋਂ ਪਹਿਲਾਂ ਇੱ ਕ ਸਿੰ ਗਲ-ਲਾਈਨ ਟਿੱ ਪਣੀ ਦੀ ਵਰਤੋਂ

ਕਰਦੀ ਹੈ:

ਉਦਾਹਰਨ

// ਇਹ ਇੱ ਕ ਟਿੱ ਪਣੀ ਹੈ

cout << "ਹੈਲੋ ਵਰਲਡ!";

ਇਹ ਉਦਾਹਰਨ ਕੋਡ ਦੀ ਇੱ ਕ ਲਾਈਨ ਦੇ ਅੰ ਤ ਵਿੱ ਚ ਇੱ ਕ ਸਿੰ ਗਲ-ਲਾਈਨ ਟਿੱ ਪਣੀ ਦੀ ਵਰਤੋਂ

ਕਰਦੀ ਹੈ:

ਉਦਾਹਰਨ

cout << "ਹੈਲੋ ਵਰਲਡ!"; // ਇਹ ਇੱ ਕ ਟਿੱ ਪਣੀ ਹੈ

_____________________________________________

2. C++ ਮਲਟੀ-ਲਾਈਨ ਟਿੱ ਪਣੀਆਂ

ਮਲਟੀ-ਲਾਈਨ ਟਿੱ ਪਣੀਆਂ /* ਨਾਲ ਸ਼ੁਰੂ ਹੁੰ ਦੀਆਂ ਹਨ ਅਤੇ */ ਨਾਲ ਖਤਮ ਹੁੰ ਦੀਆਂ ਹਨ।

/* ਅਤੇ */ ਵਿਚਕਾਰ ਕੋਈ ਵੀ ਟੈਕਸਟ ਕੰ ਪਾਈਲਰ ਦੁਆਰਾ ਅਣਡਿੱ ਠ ਕੀਤਾ ਜਾਵੇਗਾ:

ਉਦਾਹਰਨ

/* ਹੇਠਾਂ ਦਿੱ ਤਾ ਕੋਡ ਹੈਲੋ ਵਰਲਡ ਸ਼ਬਦਾਂ ਨੂੰ ਪ੍ਰਿੰ ਟ ਕਰੇਗਾ!

ਸਕ੍ਰੀਨ ਤੇ, ਅਤੇ ਇਹ ਸ਼ਾਨਦਾਰ ਹੈ */

cout << "ਹੈਲੋ ਵਰਲਡ!";

Q.10 C++ Variables?

ANS:Variables are containers for storing data values.

In C++, there are different types of variables (defined with different keywords),
for example:
 int - stores integers (whole numbers), without decimals, such as 123 or -
123
 double - stores floating point numbers, with decimals, such as 19.99 or -
19.99
 char - stores single characters, such as 'a' or 'B'. Char values are
surrounded by single quotes
 string - stores text, such as "Hello World". String values are surrounded
by double quotes
 bool - stores values with two states: true or false

ANS: ਵੇਰੀਏਬਲ ਡੇਟਾ ਮੁੱ ਲਾਂ ਨੂੰ ਸਟੋਰ ਕਰਨ ਲਈ ਕੰ ਟੇਨਰ ਹੁੰ ਦੇ ਹਨ।

C++ ਵਿੱ ਚ, ਵੱ ਖ-ਵੱ ਖ ਕਿਸਮਾਂ ਦੇ ਵੇਰੀਏਬਲ ਹਨ (ਵੱ ਖ-ਵੱ ਖ ਕੀਵਰਡਸ ਨਾਲ ਪਰਿਭਾਸ਼ਿਤ),
ਉਦਾਹਰਨ ਲਈ:

• int - ਦਸ਼ਮਲਵ ਤੋਂ ਬਿਨਾਂ ਪੂਰਨ ਅੰ ਕ (ਪੂਰੀਆਂ ਸੰ ਖਿਆਵਾਂ) ਸਟੋਰ ਕਰਦਾ ਹੈ, ਜਿਵੇਂ ਕਿ 123 ਜਾਂ
-123

• ਡਬਲ - ਫਲੋਟਿੰ ਗ ਪੁਆਇੰ ਟ ਨੰ ਬਰ ਸਟੋਰ ਕਰਦਾ ਹੈ, ਦਸ਼ਮਲਵ ਦੇ ਨਾਲ, ਜਿਵੇਂ ਕਿ 19.99 ਜਾਂ
-19.99

• char - ਸਿੰ ਗਲ ਅੱ ਖਰ ਸਟੋਰ ਕਰਦਾ ਹੈ, ਜਿਵੇਂ ਕਿ 'a' ਜਾਂ 'B'। ਚਾਰ ਮੁੱ ਲ ਸਿੰ ਗਲ ਕੋਟਸ ਨਾਲ
ਘਿਰੇ ਹੋਏ ਹਨ

• ਸਤਰ - ਸਟੋਰ ਟੈਕਸਟ, ਜਿਵੇਂ ਕਿ "ਹੈਲੋ ਵਰਲਡ"। ਸਟ੍ਰਿੰ ਗ ਮੁੱ ਲ ਡਬਲ ਕੋਟਸ ਨਾਲ ਘਿਰੇ ਹੋਏ
ਹਨ

• bool - ਮੁੱ ਲਾਂ ਨੂੰ ਦੋ ਅਵਸਥਾਵਾਂ ਨਾਲ ਸਟੋਰ ਕਰਦਾ ਹੈ: ਸਹੀ ਜਾਂ ਗਲਤ
Q.11 C++ Basic Syntax ? (2 MARKS / 10 MARKS)

1. Header File

The header files contain the definition of the functions and macros we are
using in our program. They are defined on the top of the C++ program.
In line #1, we used the #include <iostream> statement to tell the compiler to
include an iostream header file library which stores the definition of the cin
and cout methods that we have used for input and output. #include is a
preprocessor directive using which we import header files.
1. ਹੈਡਰ ਫਾਈਲ

ਹੈਡਰ ਫਾਈਲਾਂ ਵਿੱ ਚ ਫੰ ਕਸ਼ਨਾਂ ਅਤੇ ਮੈਕਰੋ ਦੀ ਪਰਿਭਾਸ਼ਾ ਹੁੰ ਦੀ ਹੈ ਜੋ ਅਸੀਂ ਆਪਣੇ ਪ੍ਰੋਗਰਾਮ

ਵਿੱ ਚ ਵਰਤ ਰਹੇ ਹਾਂ। ਉਹਨਾਂ ਨੂੰ C++ ਪ੍ਰੋਗਰਾਮ ਦੇ ਸਿਖਰ 'ਤੇ ਪਰਿਭਾਸ਼ਿਤ ਕੀਤਾ ਗਿਆ ਹੈ।

ਲਾਈਨ #1 ਵਿੱ ਚ, ਅਸੀਂ ਕੰ ਪਾਈਲਰ ਨੂੰ ਇੱ ਕ iostream ਹੈਡਰ ਫਾਈਲ ਲਾਇਬ੍ਰੇਰੀ ਨੂੰ ਸ਼ਾਮਲ

ਕਰਨ ਲਈ ਦੱ ਸਣ ਲਈ #include <iostream> ਸਟੇਟਮੈਂਟ ਦੀ ਵਰਤੋਂ ਕੀਤੀ ਹੈ ਜੋ ਕਿ cin

ਅਤੇ cout ਵਿਧੀਆਂ ਦੀ ਪਰਿਭਾਸ਼ਾ ਨੂੰ ਸਟੋਰ ਕਰਦੀ ਹੈ ਜੋ ਅਸੀਂ ਇਨਪੁਟ ਅਤੇ ਆਉਟਪੁੱ ਟ

ਲਈ ਵਰਤੀਆਂ ਹਨ। #include ਇੱ ਕ ਪ੍ਰੀਪ੍ਰੋਸੈਸਰ ਡਾਇਰੈਕਟਿਵ ਹੈ ਜਿਸਦੀ ਵਰਤੋਂ ਕਰਕੇ

ਅਸੀਂ ਹੈਡਰ ਫਾਈਲਾਂ ਨੂੰ ਆਯਾਤ ਕਰਦੇ ਹਾਂ।


2. Namespace

A namespace in C++ is used to provide a scope or a region where we define


identifiers. It is used to avoid name conflicts between two identifiers as only
unique names can be used as identifiers.
In line #2, we have used the using namespace std statement for specifying
that we will be the standard namespace where all the standard library
functions are defined.
Syntax:
using namespace std;
2. ਨੇ ਮਸਪੇਸ

C++ ਵਿੱ ਚ ਇੱ ਕ ਨੇ ਮਸਪੇਸ ਦੀ ਵਰਤੋਂ ਇੱ ਕ ਸਕੋਪ ਜਾਂ ਇੱ ਕ ਖੇਤਰ ਪ੍ਰਦਾਨ ਕਰਨ ਲਈ ਕੀਤੀ
ਜਾਂਦੀ ਹੈ ਜਿੱ ਥੇ ਅਸੀਂ ਪਛਾਣਕਰਤਾਵਾਂ ਨੂੰ ਪਰਿਭਾਸ਼ਿਤ ਕਰਦੇ ਹਾਂ। ਇਸਦੀ ਵਰਤੋਂ ਦੋ
ਪਛਾਣਕਰਤਾਵਾਂ ਵਿਚਕਾਰ ਨਾਮ ਦੇ ਟਕਰਾਅ ਤੋਂ ਬਚਣ ਲਈ ਕੀਤੀ ਜਾਂਦੀ ਹੈ ਕਿਉਂਕਿ ਸਿਰਫ
ਵਿਲੱ ਖਣ ਨਾਮ ਪਛਾਣਕਰਤਾਵਾਂ ਵਜੋਂ ਵਰਤੇ ਜਾ ਸਕਦੇ ਹਨ।

ਲਾਈਨ #2 ਵਿੱ ਚ, ਅਸੀਂ ਇਹ ਦੱ ਸਣ ਲਈ ਕਿ ਅਸੀਂ ਸਟੈਂਡਰਡ ਨੇ ਮਸਪੇਸ ਹੋਵਾਂਗੇ ਜਿੱ ਥੇ ਸਾਰੇ


ਸਟੈਂਡਰਡ ਲਾਇਬ੍ਰੇਰੀ ਫੰ ਕਸ਼ਨਾਂ ਨੂੰ ਪਰਿਭਾਸ਼ਿਤ ਕਰਨ ਲਈ ਨੇ ਮਸਪੇਸ std ਸਟੇਟਮੈਂਟ ਦੀ ਵਰਤੋਂ
ਕੀਤੀ ਹੈ।

ਸੰ ਟੈਕਸ:

ਨੇ ਮਸਪੇਸ std ਵਰਤਦੇ ਹੋਏ;

3. Main Function

Functions are basic building blocks of a C++ program that contains the
instructions for performing some specific task. Apart from the instructions
present in its body, a function definition also contains information about its
return type and parameters. To know more about C++ functions, please refer
to the article Functions in C++.
In line #3, we defined the main function as int main(). The main function is
the most important part of any C++ program. The program execution always
starts from the main function. All the other functions are called from the
main function. In C++, the main function is required to return some value
indicating the execution status.
Syntax:
int main() {
... code ....
return 0;
}
3. ਮੁੱ ਖ ਫੰ ਕਸ਼ਨ
ਫੰ ਕਸ਼ਨ ਇੱ ਕ C++ ਪ੍ਰੋਗਰਾਮ ਦੇ ਬੁਨਿਆਦੀ ਬਿਲਡਿੰ ਗ ਬਲਾਕ ਹੁੰ ਦੇ ਹਨ ਜਿਸ ਵਿੱ ਚ ਕੁਝ ਖਾਸ
ਕੰ ਮ ਕਰਨ ਲਈ ਹਦਾਇਤਾਂ ਹੁੰ ਦੀਆਂ ਹਨ। ਇਸਦੇ ਸਰੀਰ ਵਿੱ ਚ ਮੌਜੂਦ ਨਿਰਦੇਸ਼ਾਂ ਤੋਂ ਇਲਾਵਾ,
ਇੱ ਕ ਫੰ ਕਸ਼ਨ ਪਰਿਭਾਸ਼ਾ ਵਿੱ ਚ ਇਸਦੇ ਵਾਪਸੀ ਦੀ ਕਿਸਮ ਅਤੇ ਮਾਪਦੰ ਡਾਂ ਬਾਰੇ ਵੀ ਜਾਣਕਾਰੀ
ਹੁੰ ਦੀ ਹੈ। C++ ਫੰ ਕਸ਼ਨਾਂ ਬਾਰੇ ਹੋਰ ਜਾਣਨ ਲਈ, ਕਿਰਪਾ ਕਰਕੇ C++ ਵਿੱ ਚ ਫੰ ਕਸ਼ਨ ਲੇਖ ਵੇਖੋ।
ਲਾਈਨ #3 ਵਿੱ ਚ, ਅਸੀਂ ਮੁੱ ਖ ਫੰ ਕਸ਼ਨ ਨੂੰ int main() ਵਜੋਂ ਪਰਿਭਾਸ਼ਿਤ ਕੀਤਾ ਹੈ। ਮੁੱ ਖ ਫੰ ਕਸ਼ਨ
ਕਿਸੇ ਵੀ C++ ਪ੍ਰੋਗਰਾਮ ਦਾ ਸਭ ਤੋਂ ਮਹੱ ਤਵਪੂਰਨ ਹਿੱ ਸਾ ਹੁੰ ਦਾ ਹੈ। ਪ੍ਰੋਗਰਾਮ ਐਗਜ਼ੀਕਿਊਸ਼ਨ
ਹਮੇਸ਼ਾ ਮੇਨ ਫੰ ਕਸ਼ਨ ਤੋਂ ਸ਼ੁਰੂ ਹੁੰ ਦਾ ਹੈ। ਬਾਕੀ ਸਾਰੇ ਫੰ ਕਸ਼ਨਾਂ ਨੂੰ ਮੇਨ ਫੰ ਕਸ਼ਨ ਤੋਂ ਬੁਲਾਇਆ
ਜਾਂਦਾ ਹੈ। C++ ਵਿੱ ਚ, ਮੁੱ ਖ ਫੰ ਕਸ਼ਨ ਨੂੰ ਐਗਜ਼ੀਕਿਊਸ਼ਨ ਸਥਿਤੀ ਨੂੰ ਦਰਸਾਉਂਦੇ ਹੋਏ ਕੁਝ ਮੁੱ ਲ
ਵਾਪਸ ਕਰਨ ਦੀ ਲੋੜ ਹੁੰ ਦੀ ਹੈ।
ਸੰ ਟੈਕਸ:
int main() {

... ਕੋਡ...
ਵਾਪਸੀ 0;
}

4. Blocks

Blocks are the group of statements that are enclosed within { } braces. They
define the scope of the identifiers and are generally used to enclose the body
of functions and control statements.
The body of the main function is from line #4 to line #9 enclosed within { }.
Syntax:
{

// Body of the Function

return 0;
}
4. ਬਲਾਕ
ਬਲਾਕ ਕਥਨਾਂ ਦਾ ਸਮੂਹ ਹੈ ਜੋ ਕਿ { } ਬਰੇਸ ਦੇ ਅੰ ਦਰ ਬੰ ਦ ਹਨ। ਉਹ ਪਛਾਣਕਰਤਾਵਾਂ ਦੇ
ਦਾਇਰੇ ਨੂੰ ਪਰਿਭਾਸ਼ਿਤ ਕਰਦੇ ਹਨ ਅਤੇ ਆਮ ਤੌਰ 'ਤੇ ਫੰ ਕਸ਼ਨਾਂ ਅਤੇ ਨਿਯੰ ਤਰਣ ਸਟੇਟਮੈਂਟਾਂ ਦੇ
ਸਰੀਰ ਨੂੰ ਨੱ ਥੀ ਕਰਨ ਲਈ ਵਰਤੇ ਜਾਂਦੇ ਹਨ।
ਮੁੱ ਖ ਫੰ ਕਸ਼ਨ ਦਾ ਮੁੱ ਖ ਭਾਗ ਲਾਈਨ #4 ਤੋਂ ਲਾਈਨ #9 ਤੱ ਕ { } ਦੇ ਅੰ ਦਰ ਬੰ ਦ ਹੈ।
ਸੰ ਟੈਕਸ:
{

// ਫੰ ਕਸ਼ਨ ਦਾ ਸਰੀਰ

ਵਾਪਸੀ 0;
}

5. Semicolons

As you may have noticed by now, each statement in the above code is
followed by a ( ; ) semicolon symbol. It is used to terminate each line of the
statement of the program. When the compiler sees this semicolon, it
terminates the operation of that line and moves to the next line.
Syntax:
any_statement ;
5. ਸੈਮੀਕੋਲਨ
ਜਿਵੇਂ ਕਿ ਤੁਸੀਂ ਹੁਣ ਤੱ ਕ ਨੋ ਟ ਕੀਤਾ ਹੋਵੇਗਾ, ਉਪਰੋਕਤ ਕੋਡ ਵਿੱ ਚ ਹਰੇਕ ਕਥਨ ਦੇ ਬਾਅਦ ਇੱ ਕ
(;) ਸੈਮੀਕੋਲਨ ਚਿੰ ਨ੍ਹ ਹੁੰ ਦਾ ਹੈ। ਇਹ ਪ੍ਰੋਗਰਾਮ ਦੇ ਸਟੇਟਮੈਂਟ ਦੀ ਹਰੇਕ ਲਾਈਨ ਨੂੰ ਖਤਮ ਕਰਨ
ਲਈ ਵਰਤਿਆ ਜਾਂਦਾ ਹੈ। ਜਦੋਂ ਕੰ ਪਾਈਲਰ ਇਸ ਸੈਮੀਕੋਲਨ ਨੂੰ ਵੇਖਦਾ ਹੈ, ਤਾਂ ਇਹ ਉਸ ਲਾਈਨ
ਦੀ ਕਾਰਵਾਈ ਨੂੰ ਖਤਮ ਕਰ ਦਿੰ ਦਾ ਹੈ ਅਤੇ ਅਗਲੀ ਲਾਈਨ 'ਤੇ ਚਲਾ ਜਾਂਦਾ ਹੈ।
ਸੰ ਟੈਕਸ:
any_statement

6. Identifiers

We use identifiers for the naming of variables, functions, and other user-
defined data types. An identifier may consist of uppercase and lowercase
alphabetical characters, underscore, and digits. The first letter must be an
underscore or an alphabet.
Example:
int num1 = 24;
int num2 = 34;
num1 & num2 are the identifiers and int is the data type.

6. ਪਛਾਣਕਰਤਾ
ਅਸੀਂ ਵੇਰੀਏਬਲਾਂ, ਫੰ ਕਸ਼ਨਾਂ, ਅਤੇ ਹੋਰ ਉਪਭੋਗਤਾ ਦੁਆਰਾ ਪਰਿਭਾਸ਼ਿਤ ਡੇਟਾ ਕਿਸਮਾਂ ਦੇ
ਨਾਮਕਰਨ ਲਈ ਪਛਾਣਕਰਤਾਵਾਂ ਦੀ ਵਰਤੋਂ ਕਰਦੇ ਹਾਂ। ਇੱ ਕ ਪਛਾਣਕਰਤਾ ਵਿੱ ਚ ਵੱ ਡੇ ਅਤੇ ਛੋਟੇ
ਅੱ ਖਰ ਅੱ ਖਰ, ਅੰ ਡਰਸਕੋਰ ਅਤੇ ਅੰ ਕ ਸ਼ਾਮਲ ਹੋ ਸਕਦੇ ਹਨ। ਪਹਿਲਾ ਅੱ ਖਰ ਇੱ ਕ ਅੰ ਡਰਸਕੋਰ
ਜਾਂ ਇੱ ਕ ਵਰਣਮਾਲਾ ਹੋਣਾ ਚਾਹੀਦਾ ਹੈ।

ਉਦਾਹਰਨ:

int num1 = 24;

int num2 = 34;


num1 ਅਤੇ num2 ਪਛਾਣਕਰਤਾ ਹਨ ਅਤੇ int ਡਾਟਾ ਕਿਸਮ ਹੈ।

7. Keywords

In the C++ programming language, there are some reserved words that are
used for some special meaning in the C++ program. It can’t be used for
identifiers.
For example, the words int, return, and using are some keywords used in our
program. These all have some predefined meaning in the C++ language.
There are total 95 keywords in C++. These are some keywords.
int void if while for auto bool break

this static new true false case char class


To know more about Identifiers and Keywords in C++, refer to the article C/C+
+ Tokens.

7. ਕੀਵਰਡਸ

C++ ਪ੍ਰੋਗਰਾਮਿੰ ਗ ਭਾਸ਼ਾ ਵਿੱ ਚ, ਕੁਝ ਰਾਖਵੇਂ ਸ਼ਬਦ ਹਨ ਜੋ C++ ਪ੍ਰੋਗਰਾਮ ਵਿੱ ਚ ਕੁਝ ਖਾਸ ਅਰਥਾਂ
ਲਈ ਵਰਤੇ ਜਾਂਦੇ ਹਨ। ਇਸਦੀ ਵਰਤੋਂ ਪਛਾਣਕਰਤਾਵਾਂ ਲਈ ਨਹੀਂ ਕੀਤੀ ਜਾ ਸਕਦੀ।

ਉਦਾਹਰਨ ਲਈ, int, return, ਅਤੇ using ਸ਼ਬਦ ਸਾਡੇ ਪ੍ਰੋਗਰਾਮ ਵਿੱ ਚ ਵਰਤੇ ਗਏ ਕੁਝ
ਕੀਵਰਡ ਹਨ। ਇਹਨਾਂ ਸਾਰਿਆਂ ਦੇ C++ ਭਾਸ਼ਾ ਵਿੱ ਚ ਕੁਝ ਪਹਿਲਾਂ ਤੋਂ ਪਰਿਭਾਸ਼ਿਤ ਅਰਥ ਹਨ।

C++ ਵਿੱ ਚ ਕੁੱ ਲ 95 ਕੀਵਰਡ ਹਨ। ਇਹ ਕੁਝ ਕੀਵਰਡ ਹਨ।

int void ਜੇਕਰ ਆਟੋ ਬੂਲ ਬਰੇਕ ਲਈ ਹੈ


ਇਹ ਸਥਿਰ ਨਵਾਂ ਸੱ ਚਾ ਝੂਠਾ ਕੇਸ ਚਾਰ ਕਲਾਸ
C++ ਵਿੱ ਚ ਆਈਡੈਂਟੀਫਾਇਰ ਅਤੇ ਕੀਵਰਡਸ ਬਾਰੇ ਹੋਰ ਜਾਣਨ ਲਈ, ਲੇਖ C/C++ ਟੋਕਨ ਵੇਖੋ।

8. Basic Output cout

In line #7, we have used the cout method which is the basic output method in
C++ to output the sum of two numbers in the standard output stream
(stdout).
Syntax:
cout << result << endl;
8. ਬੇਸਿਕ ਆਉਟਪੁੱ ਟ ਕਾਉਟ

ਲਾਈਨ #7 ਵਿੱ ਚ, ਅਸੀਂ ਸਟੈਂਡਰਡ ਆਉਟਪੁੱ ਟ ਸਟ੍ਰੀਮ (stdout) ਵਿੱ ਚ ਦੋ ਸੰ ਖਿਆਵਾਂ ਦੇ ਜੋੜ

ਨੂੰ ਆਊਟਪੁੱ ਟ ਕਰਨ ਲਈ C++ ਵਿੱ ਚ ਮੂਲ ਆਉਟਪੁੱ ਟ ਵਿਧੀ ਦੀ ਵਰਤੋਂ ਕੀਤੀ ਹੈ।

ਸੰ ਟੈਕਸ:

cout << ਨਤੀਜਾ << endl;

10 MARKS Q/A:

Q.1 OOPs Concepts?

ANS:The major purpose of C++ programming is to introduce the concept of


object orientation to the C programming language.

Object Oriented Programming is a paradigm that provides many concepts such


as inheritance, data binding, polymorphism etc.

The programming paradigm where everything is represented as an object is


known as truly object-oriented programming language. Smalltalk is considered
as the first truly object-oriented programming language.

Q.1 OOPs ਧਾਰਨਾਵਾਂ?

ANS: C++ ਪ੍ਰੋਗਰਾਮਿੰ ਗ ਦਾ ਮੁੱ ਖ ਉਦੇਸ਼ ਸੀ ਪ੍ਰੋਗਰਾਮਿੰ ਗ ਭਾਸ਼ਾ ਵਿੱ ਚ ਆਬਜੈਕਟ ਓਰੀਐਂਟੇਸ਼ਨ ਦੀ
ਧਾਰਨਾ ਨੂੰ ਪੇਸ਼ ਕਰਨਾ ਹੈ।

ਆਬਜੈਕਟ ਓਰੀਐਂਟਿਡ ਪ੍ਰੋਗਰਾਮਿੰ ਗ ਇੱ ਕ ਪੈਰਾਡਾਈਮ ਹੈ ਜੋ ਬਹੁਤ ਸਾਰੀਆਂ ਧਾਰਨਾਵਾਂ ਪ੍ਰਦਾਨ


ਕਰਦਾ ਹੈ ਜਿਵੇਂ ਕਿ ਵਿਰਾਸਤ, ਡੇਟਾ ਬਾਈਡਿੰ ਗ, ਪੋਲੀਮੋਰਫਿਜ਼ਮ ਆਦਿ।
ਪ੍ਰੋਗਰਾਮਿੰ ਗ ਪੈਰਾਡਾਈਮ ਜਿੱ ਥੇ ਹਰ ਚੀਜ਼ ਨੂੰ ਇੱ ਕ ਵਸਤੂ ਦੇ ਰੂਪ ਵਿੱ ਚ ਦਰਸਾਇਆ ਜਾਂਦਾ ਹੈ ਨੂੰ
ਸੱ ਚਮੁੱ ਚ ਆਬਜੈਕਟ-ਅਧਾਰਿਤ ਪ੍ਰੋਗਰਾਮਿੰ ਗ ਭਾਸ਼ਾ ਵਜੋਂ ਜਾਣਿਆ ਜਾਂਦਾ ਹੈ। ਸਮਾਲਟਾਕ ਨੂੰ
ਪਹਿਲੀ ਸੱ ਚਮੁੱ ਚ ਆਬਜੈਕਟ-ਅਧਾਰਿਤ ਪ੍ਰੋਗਰਾਮਿੰ ਗ ਭਾਸ਼ਾ ਮੰ ਨਿਆ ਜਾਂਦਾ ਹੈ

OOPs (Object Oriented Programming System)

Object means a real word entity such as pen, chair, table etc. 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:

OOPs (ਆਬਜੈਕਟ ਓਰੀਐਂਟਡ ਪ੍ਰੋਗਰਾਮਿੰ ਗ ਸਿਸਟਮ)

ਆਬਜੈਕਟ ਦਾ ਅਰਥ ਹੈ ਅਸਲ ਸ਼ਬਦ ਦੀ ਹਸਤੀ ਜਿਵੇਂ ਕਿ ਪੈੱਨ, ਕੁਰਸੀ, ਮੇਜ਼ ਆਦਿ।
ਆਬਜੈਕਟ-ਓਰੀਐਂਟਡ ਪ੍ਰੋਗਰਾਮਿੰ ਗ ਕਲਾਸਾਂ ਅਤੇ ਵਸਤੂਆਂ ਦੀ ਵਰਤੋਂ ਕਰਕੇ ਇੱ ਕ ਪ੍ਰੋਗਰਾਮ ਨੂੰ
ਡਿਜ਼ਾਈਨ ਕਰਨ ਲਈ ਇੱ ਕ ਵਿਧੀ ਜਾਂ ਪੈਰਾਡਾਈਮ ਹੈ। ਇਹ ਕੁਝ ਸੰ ਕਲਪਾਂ ਪ੍ਰਦਾਨ ਕਰਕੇ
ਸਾਫਟਵੇਅਰ ਵਿਕਾਸ ਅਤੇ ਰੱ ਖ-ਰਖਾਅ ਨੂੰ ਸਰਲ ਬਣਾਉਂਦਾ ਹੈ:

Backward Skip 10sPlay VideoForward Skip 10s

o Object
o Class
o Inheritance
o Polymorphism
o Abstraction
o Encapsulation
Object

Any entity that has state and behavior is known as an object. For example:
chair, pen, table, keyboard, bike etc. It can be physical and logical.

ਵਸਤੂ

ਕੋਈ ਵੀ ਇਕਾਈ ਜਿਸਦਾ ਰਾਜ ਅਤੇ ਵਿਵਹਾਰ ਹੁੰ ਦਾ ਹੈ ਨੂੰ ਇੱ ਕ ਵਸਤੂ ਵਜੋਂ ਜਾਣਿਆ ਜਾਂਦਾ ਹੈ।
ਉਦਾਹਰਨ ਲਈ: ਕੁਰਸੀ, ਪੈੱਨ, ਮੇਜ਼, ਕੀ-ਬੋਰਡ, ਸਾਈਕਲ ਆਦਿ। ਇਹ ਭੌਤਿਕ ਅਤੇ ਤਰਕਪੂਰਨ
ਹੋ ਸਕਦਾ ਹੈ।

Class

Collection of objects is called class. It is a logical entity.

A Class in C++ is the foundational element that leads to Object-Oriented


programming. A class instance must be created in order to access and use the
user-defined data type's data members and member functions. An object's
class acts as its blueprint. Take the class of cars as an example. Even if different
names and brands may be used for different cars, all of them will have some
characteristics in common, such as four wheels, a speed limit, a range of miles,
etc. In this case, the class of car is represented by the wheels, the speed
limitations, and the mileage.

ਕਲਾਸ

ਵਸਤੂਆਂ ਦੇ ਸੰ ਗ੍ਰਹਿ ਨੂੰ ਕਲਾਸ ਕਿਹਾ ਜਾਂਦਾ ਹੈ। ਇਹ ਇੱ ਕ ਤਰਕਸ਼ੀਲ ਹਸਤੀ ਹੈ।

C++ ਵਿੱ ਚ ਇੱ ਕ ਕਲਾਸ ਬੁਨਿਆਦੀ ਤੱ ਤ ਹੈ ਜੋ ਆਬਜੈਕਟ-ਓਰੀਐਂਟਡ ਪ੍ਰੋਗਰਾਮਿੰ ਗ ਵੱ ਲ ਲੈ ਜਾਂਦਾ


ਹੈ। ਉਪਭੋਗਤਾ ਦੁਆਰਾ ਪਰਿਭਾਸ਼ਿਤ ਡੇਟਾ ਕਿਸਮ ਦੇ ਡੇਟਾ ਮੈਂਬਰਾਂ ਅਤੇ ਸਦੱ ਸ ਫੰ ਕਸ਼ਨਾਂ ਨੂੰ
ਐਕਸੈਸ ਕਰਨ ਅਤੇ ਵਰਤਣ ਲਈ ਇੱ ਕ ਕਲਾਸ ਉਦਾਹਰਨ ਤਿਆਰ ਕੀਤੀ ਜਾਣੀ ਚਾਹੀਦੀ ਹੈ।
ਕਿਸੇ ਵਸਤੂ ਦੀ ਸ਼੍ਰੇਣੀ ਇਸਦੇ ਬਲੂਪ੍ਰਿੰ ਟ ਵਜੋਂ ਕੰ ਮ ਕਰਦੀ ਹੈ। ਕਾਰਾਂ ਦੀ ਸ਼੍ਰੇਣੀ ਨੂੰ ਇੱ ਕ ਉਦਾਹਰਣ
ਵਜੋਂ ਲਓ। ਭਾਵੇਂ ਵੱ ਖ-ਵੱ ਖ ਕਾਰਾਂ ਲਈ ਵੱ ਖੋ-ਵੱ ਖਰੇ ਨਾਮ ਅਤੇ ਬ੍ਰਾਂਡ ਵਰਤੇ ਜਾ ਸਕਦੇ ਹਨ, ਉਨ੍ਹਾਂ
ਸਾਰਿਆਂ ਦੀਆਂ ਕੁਝ ਵਿਸ਼ੇਸ਼ਤਾਵਾਂ ਸਾਂਝੀਆਂ ਹੋਣਗੀਆਂ, ਜਿਵੇਂ ਕਿ ਚਾਰ ਪਹੀਏ, ਇੱ ਕ ਗਤੀ ਸੀਮਾ,
ਮੀਲ ਦੀ ਇੱ ਕ ਰੇਂਜ, ਆਦਿ। ਇਸ ਮਾਮਲੇ ਵਿੱ ਚ, ਕਾਰ ਦੀ ਸ਼੍ਰੇਣੀ ਦੁਆਰਾ ਦਰਸਾਇਆ ਗਿਆ ਹੈ।
ਪਹੀਏ, ਸਪੀਡ ਸੀਮਾਵਾਂ, ਅਤੇ ਮਾਈਲੇਜ।
Inheritance

When one object acquires all the properties and behaviours of parent
object i.e. known as inheritance. It provides code reusability. It is used to
achieve runtime polymorphism.

1. Sub class - Subclass or Derived Class refers to a class that receives


properties from another class.
2. Super class - The term "Base Class" or "Super Class" refers to the class
from which a subclass inherits its properties.
3. Reusability - As a result, when we wish to create a new class, but an
existing class already contains some of the code we need, we can
generate our new class from the old class thanks to inheritance. This
allows us to utilize the fields and methods of the pre-existing class.

ਵਿਰਾਸਤ

ਜਦੋਂ ਇੱ ਕ ਵਸਤੂ ਮੂਲ ਵਸਤੂ ਦੀਆਂ ਸਾਰੀਆਂ ਵਿਸ਼ੇਸ਼ਤਾਵਾਂ ਅਤੇ ਵਿਹਾਰਾਂ ਨੂੰ ਗ੍ਰਹਿਣ ਕਰ
ਲੈਂਦੀ ਹੈ ਜਿਵੇਂ ਕਿ ਵਿਰਾਸਤ ਵਜੋਂ ਜਾਣਿਆ ਜਾਂਦਾ ਹੈ। ਇਹ ਕੋਡ ਦੀ ਮੁੜ ਵਰਤੋਂਯੋਗਤਾ
ਪ੍ਰਦਾਨ ਕਰਦਾ ਹੈ। ਇਹ ਰਨਟਾਈਮ ਪੋਲੀਮੋਰਫਿਜ਼ਮ ਨੂੰ ਪ੍ਰਾਪਤ ਕਰਨ ਲਈ ਵਰਤਿਆ
ਜਾਂਦਾ ਹੈ।

1. ਸਬ-ਕਲਾਸ - ਸਬ-ਕਲਾਸ ਜਾਂ ਡਿਰਾਈਵਡ ਕਲਾਸ ਇੱ ਕ ਕਲਾਸ ਨੂੰ ਦਰਸਾਉਂਦੀ ਹੈ ਜੋ


ਕਿਸੇ ਹੋਰ ਕਲਾਸ ਤੋਂ ਵਿਸ਼ੇਸ਼ਤਾਵਾਂ ਪ੍ਰਾਪਤ ਕਰਦੀ ਹੈ।

2. ਸੁਪਰ ਕਲਾਸ - ਸ਼ਬਦ "ਬੇਸ ਕਲਾਸ" ਜਾਂ "ਸੁਪਰ ਕਲਾਸ" ਉਸ ਕਲਾਸ ਨੂੰ ਦਰਸਾਉਂਦਾ
ਹੈ ਜਿਸ ਤੋਂ ਉਪ-ਕਲਾਸ ਆਪਣੀਆਂ ਵਿਸ਼ੇਸ਼ਤਾਵਾਂ ਪ੍ਰਾਪਤ ਕਰਦਾ ਹੈ।

3. ਮੁੜ ਵਰਤੋਂਯੋਗਤਾ - ਨਤੀਜੇ ਵਜੋਂ, ਜਦੋਂ ਅਸੀਂ ਇੱ ਕ ਨਵੀਂ ਕਲਾਸ ਬਣਾਉਣਾ ਚਾਹੁੰ ਦੇ ਹਾਂ,
ਪਰ ਇੱ ਕ ਮੌਜੂਦਾ ਕਲਾਸ ਵਿੱ ਚ ਪਹਿਲਾਂ ਹੀ ਕੁਝ ਕੋਡ ਸ਼ਾਮਲ ਹੁੰ ਦਾ ਹੈ ਜਿਸਦੀ ਸਾਨੂੰ ਲੋੜ
ਹੁੰ ਦੀ ਹੈ, ਅਸੀਂ ਵਿਰਾਸਤ ਦੇ ਕਾਰਨ ਪੁਰਾਣੀ ਕਲਾਸ ਤੋਂ ਆਪਣੀ ਨਵੀਂ ਕਲਾਸ ਬਣਾ ਸਕਦੇ
ਹਾਂ। ਇਹ ਸਾਨੂੰ ਪਹਿਲਾਂ ਤੋਂ ਮੌਜੂਦ ਕਲਾਸ ਦੇ ਖੇਤਰਾਂ ਅਤੇ ਤਰੀਕਿਆਂ ਦੀ ਵਰਤੋਂ ਕਰਨ ਦੀ
ਇਜਾਜ਼ਤ ਦਿੰ ਦਾ ਹੈ।
Polymorphism

When one task is performed by different ways i.e. known as polymorphism.


For example: to convince the customer differently, to draw something e.g.
shape or rectangle etc.

Different situations may cause an operation to behave differently. The type of


data utilized in the operation determines the behavior.

ਪੋਲੀਮੋਰਫਿਜ਼ਮ

ਜਦੋਂ ਇੱ ਕ ਕੰ ਮ ਨੂੰ ਵੱ ਖ-ਵੱ ਖ ਤਰੀਕਿਆਂ ਨਾਲ ਕੀਤਾ ਜਾਂਦਾ ਹੈ ਜਿਵੇਂ ਕਿ ਪੋਲੀਮੋਰਫਿਜ਼ਮ ਵਜੋਂ

ਜਾਣਿਆ ਜਾਂਦਾ ਹੈ। ਉਦਾਹਰਨ ਲਈ: ਗਾਹਕ ਨੂੰ ਵੱ ਖਰੇ ਢੰ ਗ ਨਾਲ ਯਕੀਨ ਦਿਵਾਉਣ ਲਈ, ਕੁਝ

ਖਿੱ ਚਣ ਲਈ ਜਿਵੇਂ ਕਿ ਸ਼ਕਲ ਜਾਂ ਆਇਤਕਾਰ ਆਦਿ

ਵੱ ਖ-ਵੱ ਖ ਸਥਿਤੀਆਂ ਕਾਰਨ ਓਪਰੇਸ਼ਨ ਵੱ ਖਰੇ ਢੰ ਗ ਨਾਲ ਵਿਵਹਾਰ ਕਰ ਸਕਦਾ ਹੈ। ਓਪਰੇਸ਼ਨ

ਵਿੱ ਚ ਵਰਤੇ ਗਏ ਡੇਟਾ ਦੀ ਕਿਸਮ ਵਿਵਹਾਰ ਨੂੰ ਨਿਰਧਾਰਤ ਕਰਦੀ ਹੈ।

Abstraction

Hiding internal details and showing functionality is known as abstraction.


Data abstraction is the process of exposing to the outside world only the
information that is absolutely necessary while concealing implementation or
background information.For example: phone call, we don't know the internal
processing.

In C++, we use abstract class and interface to achieve abstraction.

ਐਬਸਟਰੈਕਸ਼ਨ

ਅੰ ਦਰੂਨੀ ਵੇਰਵਿਆਂ ਨੂੰ ਲੁਕਾਉਣਾ ਅਤੇ ਕਾਰਜਕੁਸ਼ਲਤਾ ਦਿਖਾਉਣ ਨੂੰ ਐਬਸਟਰੈਕਸ਼ਨ ਵਜੋਂ
ਜਾਣਿਆ ਜਾਂਦਾ ਹੈ। ਡੇਟਾ ਐਬਸਟਰੈਕਸ਼ਨ ਸਿਰਫ ਉਹ ਜਾਣਕਾਰੀ ਨੂੰ ਬਾਹਰੀ ਸੰ ਸਾਰ ਦੇ ਸਾਹਮਣੇ
ਲਿਆਉਣ ਦੀ ਪ੍ਰਕਿਰਿਆ ਹੈ ਜੋ ਲਾਗੂ ਕਰਨ ਜਾਂ ਪਿਛੋਕੜ ਦੀ ਜਾਣਕਾਰੀ ਨੂੰ ਛੁਪਾਉਂਦੇ ਹੋਏ
ਬਿਲਕੁਲ ਜ਼ਰੂਰੀ ਹੈ। ਉਦਾਹਰਨ ਲਈ: ਫ਼ੋਨ ਕਾਲ, ਸਾਨੂੰ ਅੰ ਦਰੂਨੀ ਪ੍ਰਕਿਰਿਆ ਬਾਰੇ ਨਹੀਂ ਪਤਾ।

C++ ਵਿੱ ਚ, ਅਸੀਂ ਐਬਸਟਰੈਕਟ ਪ੍ਰਾਪਤ ਕਰਨ ਲਈ ਐਬਸਟਰੈਕਟ ਕਲਾਸ ਅਤੇ ਇੰ ਟਰਫੇਸ ਦੀ
ਵਰਤੋਂ ਕਰਦੇ ਹਾਂ
Encapsulation

Binding (or wrapping) code and data together into a single unit is known as
encapsulation. For example: capsule, it is wrapped with different medicines.

Encapsulation is typically understood as the grouping of related pieces of


information and data into a single entity. Encapsulation is the process of tying
together data and the functions that work with it in object-oriented
programming. Take a look at a practical illustration of encapsulation: at a
company, there are various divisions, including the sales division, the finance
division, and the accounts division. All financial transactions are handled by the
finance sector, which also maintains records of all financial data. In a similar
vein, the sales section is in charge of all tasks relating to sales and maintains a
record of each sale. Now, a scenario could occur when, for some reason, a
financial official requires all the information on sales for a specific month.
Under the umbrella term "sales section," all of the employees who can
influence the sales section's data are grouped together. Data abstraction or
concealing is another side effect of encapsulation. In the same way that
encapsulation hides the data. In the aforementioned example, any other area
cannot access any of the data from any of the sections, such as sales, finance,
or accounts.

ਇਨਕੈਪਸੂਲੇਸ਼ਨ

ਬਾਈਡਿੰ ਗ (ਜਾਂ ਰੈਪਿੰ ਗ) ਕੋਡ ਅਤੇ ਡੇਟਾ ਨੂੰ ਇੱ ਕ ਸਿੰ ਗਲ ਯੂਨਿਟ ਵਿੱ ਚ ਇਕੱ ਠੇ ਕਰਨ ਨੂੰ
ਐਨਕੈਪਸੂਲੇਸ਼ਨ ਵਜੋਂ ਜਾਣਿਆ ਜਾਂਦਾ ਹੈ। ਉਦਾਹਰਨ ਲਈ: ਕੈਪਸੂਲ, ਇਸ ਨੂੰ ਵੱ ਖ-ਵੱ ਖ ਦਵਾਈਆਂ
ਨਾਲ ਲਪੇਟਿਆ ਜਾਂਦਾ ਹੈ।

ਇਨਕੈਪਸੂਲੇਸ਼ਨ ਨੂੰ ਆਮ ਤੌਰ 'ਤੇ ਇੱ ਕ ਇਕਾਈ ਵਿੱ ਚ ਜਾਣਕਾਰੀ ਅਤੇ ਡੇਟਾ ਦੇ ਸਬੰ ਧਤ
ਟੁਕੜਿਆਂ ਦੇ ਸਮੂਹ ਦੇ ਰੂਪ ਵਿੱ ਚ ਸਮਝਿਆ ਜਾਂਦਾ ਹੈ। ਐਨਕੈਪਸੂਲੇਸ਼ਨ ਡੇਟਾ ਅਤੇ ਫੰ ਕਸ਼ਨਾਂ ਨੂੰ
ਜੋੜਨ ਦੀ ਪ੍ਰਕਿਰਿਆ ਹੈ ਜੋ ਆਬਜੈਕਟ-ਓਰੀਐਂਟਡ ਪ੍ਰੋਗਰਾਮਿੰ ਗ ਵਿੱ ਚ ਇਸਦੇ ਨਾਲ ਕੰ ਮ ਕਰਦੇ
ਹਨ। ਇਨਕੈਪਸੂਲੇਸ਼ਨ ਦੇ ਇੱ ਕ ਵਿਹਾਰਕ ਦ੍ਰਿਸ਼ਟੀਕੋਣ 'ਤੇ ਇੱ ਕ ਨਜ਼ਰ ਮਾਰੋ: ਇੱ ਕ ਕੰ ਪਨੀ ਵਿੱ ਚ,
ਵਿਕਰੀ ਡਿਵੀਜ਼ਨ, ਵਿੱ ਤ ਡਿਵੀਜ਼ਨ, ਅਤੇ ਅਕਾਊਂਟਸ ਡਿਵੀਜ਼ਨ ਸਮੇਤ ਵੱ ਖ-ਵੱ ਖ ਡਿਵੀਜ਼ਨਾਂ ਹਨ।
ਸਾਰੇ ਵਿੱ ਤੀ ਲੈਣ-ਦੇਣ ਵਿੱ ਤ ਸੈਕਟਰ ਦੁਆਰਾ ਸੰ ਭਾਲੇ ਜਾਂਦੇ ਹਨ, ਜੋ ਸਾਰੇ ਵਿੱ ਤੀ ਡੇਟਾ ਦੇ ਰਿਕਾਰਡ
ਵੀ ਰੱ ਖਦਾ ਹੈ। ਇਸੇ ਤਰ੍ਹਾਂ, ਸੇਲਜ਼ ਸੈਕਸ਼ਨ ਵਿਕਰੀ ਨਾਲ ਸਬੰ ਧਤ ਸਾਰੇ ਕੰ ਮਾਂ ਦਾ ਇੰ ਚਾਰਜ ਹੁੰ ਦਾ
ਹੈ ਅਤੇ ਹਰੇਕ ਵਿਕਰੀ ਦਾ ਰਿਕਾਰਡ ਰੱ ਖਦਾ ਹੈ। ਹੁਣ, ਇੱ ਕ ਦ੍ਰਿਸ਼ ਉਦੋਂ ਵਾਪਰ ਸਕਦਾ ਹੈ ਜਦੋਂ,
ਕਿਸੇ ਕਾਰਨ ਕਰਕੇ, ਇੱ ਕ ਵਿੱ ਤੀ ਅਧਿਕਾਰੀ ਨੂੰ ਇੱ ਕ ਖਾਸ ਮਹੀਨੇ ਲਈ ਵਿਕਰੀ ਬਾਰੇ ਸਾਰੀ
ਜਾਣਕਾਰੀ ਦੀ ਲੋੜ ਹੁੰ ਦੀ ਹੈ। ਛਤਰੀ ਸ਼ਬਦ "ਸੇਲਜ਼ ਸੈਕਸ਼ਨ" ਦੇ ਤਹਿਤ, ਉਹ ਸਾਰੇ ਕਰਮਚਾਰੀ
ਜੋ ਸੇਲਜ਼ ਸੈਕਸ਼ਨ ਦੇ ਡੇਟਾ ਨੂੰ ਪ੍ਰਭਾਵਿਤ ਕਰ ਸਕਦੇ ਹਨ, ਨੂੰ ਇਕੱ ਠੇ ਗਰੁੱ ਪ ਕੀਤਾ ਗਿਆ ਹੈ।
ਡੇਟਾ ਐਬਸਟਰੈਕਸ਼ਨ ਜਾਂ ਛੁਪਾਉਣਾ ਇਨਕੈਪਸੂਲੇਸ਼ਨ ਦਾ ਇੱ ਕ ਹੋਰ ਮਾੜਾ ਪ੍ਰਭਾਵ ਹੈ। ਉਸੇ
ਤਰੀਕੇ ਨਾਲ ਜੋ ਐਨਕੈਪਸੂਲੇਸ਼ਨ ਡੇਟਾ ਨੂੰ ਲੁਕਾਉਂਦਾ ਹੈ. ਉਪਰੋਕਤ ਉਦਾਹਰਨ ਵਿੱ ਚ, ਕੋਈ ਵੀ
ਹੋਰ ਖੇਤਰ ਕਿਸੇ ਵੀ ਸੈਕਸ਼ਨ, ਜਿਵੇਂ ਕਿ ਵਿਕਰੀ, ਵਿੱ ਤ, ਜਾਂ ਖਾਤਿਆਂ ਦੇ ਕਿਸੇ ਵੀ ਡੇਟਾ ਤੱ ਕ ਪਹੁੰ ਚ
ਨਹੀਂ ਕਰ ਸਕਦਾ ਹੈ।

Dynamic Binding - In dynamic binding, a decision is made at runtime regarding


the code that will be run in response to a function call. For this, C++ supports
virtual functions.

ਡਾਇਨਾਮਿਕ ਬਾਈਡਿੰ ਗ - ਡਾਇਨਾਮਿਕ ਬਾਈਡਿੰ ਗ ਵਿੱ ਚ, ਇੱ ਕ ਫੰ ਕਸ਼ਨ ਕਾਲ ਦੇ ਜਵਾਬ


ਵਿੱ ਚ ਚੱ ਲਣ ਵਾਲੇ ਕੋਡ ਦੇ ਸਬੰ ਧ ਵਿੱ ਚ ਰਨਟਾਈਮ 'ਤੇ ਇੱ ਕ ਫੈਸਲਾ ਲਿਆ ਜਾਂਦਾ ਹੈ। ਇਸਦੇ
ਲਈ, C++ ਵਰਚੁਅਲ ਫੰ ਕਸ਼ਨਾਂ ਦਾ ਸਮਰਥਨ ਕਰਦਾ ਹੈ।

Q.2 Advantage of OOPs over Procedure-oriented programming language

1. OOPs makes development and maintenance easier where as in


Procedure-oriented programming language it is not easy to manage if
code grows as project size grows.
2. OOPs provide data hiding whereas in Procedure-oriented programming
language a global data can be accessed from anywhere.
3. OOPs provide ability to simulate real-world event much more effectively.
We can provide the solution of real word problem if we are using the
Object-Oriented Programming language.

Q.2 ਪ੍ਰਕਿਰਿਆ-ਅਧਾਰਿਤ ਪ੍ਰੋਗਰਾਮਿੰ ਗ ਭਾਸ਼ਾ ਉੱਤੇ OOPs ਦਾ ਫਾਇਦਾ

1. OOPs ਵਿਕਾਸ ਅਤੇ ਰੱ ਖ-ਰਖਾਅ ਨੂੰ ਆਸਾਨ ਬਣਾਉਂਦੇ ਹਨ ਜਿੱ ਥੇ ਪ੍ਰਕਿਰਿਆ-ਅਧਾਰਿਤ


ਪ੍ਰੋਗ੍ਰਾਮਿੰ ਗ ਭਾਸ਼ਾ ਵਿੱ ਚ ਇਹ ਪ੍ਰਬੰ ਧਨ ਕਰਨਾ ਆਸਾਨ ਨਹੀਂ ਹੁੰ ਦਾ ਹੈ ਜੇਕਰ ਕੋਡ ਪ੍ਰੋਜੈਕਟ
ਦਾ ਆਕਾਰ ਵਧਣ ਨਾਲ ਵਧਦਾ ਹੈ।

2. OOPs ਡੇਟਾ ਨੂੰ ਛੁਪਾਉਂਦੇ ਹਨ ਜਦੋਂ ਕਿ ਪ੍ਰਕਿਰਿਆ-ਅਧਾਰਿਤ ਪ੍ਰੋਗਰਾਮਿੰ ਗ ਭਾਸ਼ਾ ਵਿੱ ਚ


ਇੱ ਕ ਗਲੋਬਲ ਡੇਟਾ ਨੂੰ ਕਿਤੇ ਵੀ ਪਹੁੰ ਚਿਆ ਜਾ ਸਕਦਾ ਹੈ।

3. OOPs ਅਸਲ-ਸੰ ਸਾਰ ਘਟਨਾ ਨੂੰ ਵਧੇਰੇ ਪ੍ਰਭਾਵਸ਼ਾਲੀ ਢੰ ਗ ਨਾਲ ਨਕਲ ਕਰਨ ਦੀ
ਸਮਰੱ ਥਾ ਪ੍ਰਦਾਨ ਕਰਦੇ ਹਨ। ਅਸੀਂ ਅਸਲ ਸ਼ਬਦ ਸਮੱ ਸਿਆ ਦਾ ਹੱ ਲ ਪ੍ਰਦਾਨ ਕਰ ਸਕਦੇ
ਹਾਂ ਜੇਕਰ ਅਸੀਂ ਆਬਜੈਕਟ-ਓਰੀਐਂਟਡ ਪ੍ਰੋਗਰਾਮਿੰ ਗ ਭਾਸ਼ਾ ਦੀ ਵਰਤੋਂ ਕਰ ਰਹੇ ਹਾਂ
Q.3 Why do we need oops in C++?

There were various drawbacks to the early methods of programming, as well


as poor performance. The approach couldn't effectively address real-world
issues since, similar to procedural-oriented programming, you couldn't reuse
the code within the program again, there was a difficulty with global data
access, and so on.

With the use of classes and objects, object-oriented programming makes code
maintenance simple. Because inheritance allows for code reuse, the program is
simpler because you don't have to write the same code repeatedly. Data hiding
is also provided by ideas like encapsulation and abstraction.

Q.3 ਸਾਨੂੰ C++ ਵਿੱ ਚ ਓਫ ਦੀ ਲੋੜ ਕਿਉਂ ਹੈ?

ਪ੍ਰੋਗਰਾਮਿੰ ਗ ਦੇ ਸ਼ੁਰੂਆਤੀ ਤਰੀਕਿਆਂ ਵਿੱ ਚ ਕਈ ਕਮੀਆਂ ਸਨ, ਨਾਲ ਹੀ ਮਾੜੀ ਕਾਰਗੁਜ਼ਾਰੀ ਵੀ।
ਪਹੁੰ ਚ ਅਸਲ-ਸੰ ਸਾਰ ਦੇ ਮੁੱ ਦਿਆਂ ਨੂੰ ਪ੍ਰਭਾਵਸ਼ਾਲੀ ਢੰ ਗ ਨਾਲ ਹੱ ਲ ਨਹੀਂ ਕਰ ਸਕੀ ਕਿਉਂਕਿ,
ਪ੍ਰਕਿਰਿਆ-ਅਧਾਰਿਤ ਪ੍ਰੋਗਰਾਮਿੰ ਗ ਦੇ ਸਮਾਨ, ਤੁਸੀਂ ਪ੍ਰੋਗਰਾਮ ਦੇ ਅੰ ਦਰ ਕੋਡ ਦੀ ਦੁਬਾਰਾ ਵਰਤੋਂ
ਨਹੀਂ ਕਰ ਸਕਦੇ, ਗਲੋਬਲ ਡਾਟਾ ਐਕਸੈਸ ਵਿੱ ਚ ਇੱ ਕ ਮੁਸ਼ਕਲ ਸੀ, ਆਦਿ।

ਕਲਾਸਾਂ ਅਤੇ ਆਬਜੈਕਟ ਦੀ ਵਰਤੋਂ ਨਾਲ, ਆਬਜੈਕਟ-ਓਰੀਐਂਟਡ ਪ੍ਰੋਗਰਾਮਿੰ ਗ ਕੋਡ ਮੇਨਟੇਨੈਂ ਸ ਨੂੰ
ਸਰਲ ਬਣਾਉਂਦੀ ਹੈ। ਕਿਉਂਕਿ ਵਿਰਾਸਤ ਕੋਡ ਦੀ ਮੁੜ ਵਰਤੋਂ ਦੀ ਆਗਿਆ ਦਿੰ ਦੀ ਹੈ, ਪ੍ਰੋਗਰਾਮ
ਸੌਖਾ ਹੈ ਕਿਉਂਕਿ ਤੁਹਾਨੂੰ ਉਹੀ ਕੋਡ ਵਾਰ-ਵਾਰ ਲਿਖਣ ਦੀ ਲੋੜ ਨਹੀਂ ਹੈ। ਇਨਕੈਪਸੂਲੇਸ਼ਨ ਅਤੇ
ਐਬਸਟਰੈਕਸ਼ਨ ਵਰਗੇ ਵਿਚਾਰਾਂ ਦੁਆਰਾ ਡਾਟਾ ਲੁਕਾਉਣਾ ਵੀ ਪ੍ਰਦਾਨ ਕੀਤਾ ਜਾਂਦਾ ਹੈ।

Q.4 GIVE SUITABLE EXAMPLE OF C++ Program?

ANS:

1. #include <iostream.h>
2. #include<conio.h>
3. void main() {
4. clrscr();
5. cout << "Welcome to C++ Programming.";
6. getch();
7. }

#include<iostream.h> includes the standard input output library functions. It


provides cin and cout methods for reading from input and writing to output
respectively.
#include <conio.h> includes the console input output library functions. The
getch() function is defined in conio.h file.

void main() The main() function is the entry point of every program in C++
language. The void keyword specifies that it returns no value.

cout << "Welcome to C++ Programming." is used to print the data "Welcome
to C++ Programming." on the console.

getch() The getch() function asks for a single character. Until you press any
key, it blocks the screen.

#include<iostream.h> ਵਿੱ ਚ ਮਿਆਰੀ ਇਨਪੁਟ ਆਉਟਪੁੱ ਟ ਲਾਇਬ੍ਰੇਰੀ ਫੰ ਕਸ਼ਨ ਸ਼ਾਮਲ ਹਨ।


ਇਹ ਕ੍ਰਮਵਾਰ ਇਨਪੁਟ ਤੋਂ ਪੜ੍ਹਨ ਅਤੇ ਆਉਟਪੁੱ ਟ ਨੂੰ ਲਿਖਣ ਲਈ cin ਅਤੇ cout ਢੰ ਗ ਪ੍ਰਦਾਨ
ਕਰਦਾ ਹੈ।

#include <conio.h> ਵਿੱ ਚ ਕੰ ਸੋਲ ਇੰ ਪੁੱ ਟ ਆਉਟਪੁੱ ਟ ਲਾਇਬ੍ਰੇਰੀ ਫੰ ਕਸ਼ਨ ਸ਼ਾਮਲ ਹਨ।
getch() ਫੰ ਕਸ਼ਨ conio.h ਫਾਈਲ ਵਿੱ ਚ ਪਰਿਭਾਸ਼ਿਤ ਕੀਤਾ ਗਿਆ ਹੈ।

void main() main() ਫੰ ਕਸ਼ਨ C++ ਭਾਸ਼ਾ ਵਿੱ ਚ ਹਰੇਕ ਪ੍ਰੋਗਰਾਮ ਦਾ ਐਂਟਰੀ ਪੁਆਇੰ ਟ ਹੈ। void
ਕੀਵਰਡ ਦਰਸਾਉਂਦਾ ਹੈ ਕਿ ਇਹ ਕੋਈ ਮੁੱ ਲ ਨਹੀਂ ਦਿੰ ਦਾ ਹੈ।

cout << "C++ ਪ੍ਰੋਗਰਾਮਿੰ ਗ ਵਿੱ ਚ ਤੁਹਾਡਾ ਸੁਆਗਤ ਹੈ।" ਡਾਟਾ ਪ੍ਰਿੰ ਟ ਕਰਨ ਲਈ ਵਰਤਿਆ
ਜਾਂਦਾ ਹੈ "C++ ਪ੍ਰੋਗਰਾਮਿੰ ਗ ਵਿੱ ਚ ਤੁਹਾਡਾ ਸੁਆਗਤ ਹੈ।" ਕੰ ਸੋਲ 'ਤੇ.

getch() getch() ਫੰ ਕਸ਼ਨ ਇੱ ਕ ਸਿੰ ਗਲ ਅੱ ਖਰ ਲਈ ਪੁੱ ਛਦਾ ਹੈ। ਜਦੋਂ ਤੱ ਕ ਤੁਸੀਂ ਕੋਈ ਵੀ ਕੁੰ ਜੀ
ਨਹੀਂ ਦਬਾਉਂਦੇ, ਇਹ ਸਕ੍ਰੀਨ ਨੂੰ ਬਲੌ ਕ ਕਰ ਦਿੰ ਦਾ ਹੈ।

Q.5 How to compile and run the C++ program?


ANS: There are 2 ways to compile and run the C++ program, by menu and by
shortcut.

1. By menu

Now click on the compile menu then compile sub menu to compile the c++
program.

Then click on the run menu then run sub menu to run the c++ program.

2. By shortcut

Or, press ctrl+f9 keys compile and run the program directly.

You will see the following output on user screen.

Q.5 C++ ਪ੍ਰੋਗਰਾਮ ਨੂੰ ਕੰ ਪਾਇਲ ਅਤੇ ਰਨ ਕਿਵੇਂ ਕਰੀਏ?

ANS: C++ ਪ੍ਰੋਗਰਾਮ ਨੂੰ ਕੰ ਪਾਇਲ ਕਰਨ ਅਤੇ ਚਲਾਉਣ ਦੇ 2 ਤਰੀਕੇ ਹਨ, ਮੇਨੂ ਅਤੇ ਸ਼ਾਰਟਕੱ ਟ
ਦੁਆਰਾ।

1. ਮੀਨੂ ਦੁਆਰਾ

ਹੁਣ ਕੰ ਪਾਇਲ ਮੀਨੂ 'ਤੇ ਕਲਿੱ ਕ ਕਰੋ ਫਿਰ c++ ਪ੍ਰੋਗਰਾਮ ਨੂੰ ਕੰ ਪਾਇਲ ਕਰਨ ਲਈ ਕੰ ਪਾਇਲ ਸਬ
ਮੀਨੂ 'ਤੇ ਕਲਿੱ ਕ ਕਰੋ।

ਫਿਰ c++ ਪ੍ਰੋਗਰਾਮ ਨੂੰ ਚਲਾਉਣ ਲਈ ਰਨ ਮੀਨੂ 'ਤੇ ਕਲਿੱ ਕ ਕਰੋ ਫਿਰ ਸਬ ਮੀਨੂ ਚਲਾਓ।

2. ਸ਼ਾਰਟਕੱ ਟ ਦੁਆਰਾ

ਜਾਂ, ctrl+f9 ਬਟਨ ਦਬਾਓ ਅਤੇ ਪ੍ਰੋਗਰਾਮ ਨੂੰ ਸਿੱ ਧਾ ਚਲਾਓ।

ਤੁਸੀਂ ਉਪਭੋਗਤਾ ਸਕ੍ਰੀਨ ਤੇ ਹੇਠਾਂ ਦਿੱ ਤੀ ਆਉਟਪੁੱ ਟ ਵੇਖੋਗੇ.


You can view the user screen any time by pressing the alt+f5 keys.

Now press Esc to return to the turbo c++ console.

Q.6 C++ Basic Input/Output?

ANS: C++ I/O operation is using the stream concept. Stream is the sequence of
bytes or flow of data. It makes the performance fast.

If bytes flow from main memory to device like printer, display screen, or a
network connection, etc, this is called as output operation.

If bytes flow from device like printer, display screen, or a network connection,
etc to main memory, this is called as input operation.

Q.6 C++ ਬੇਸਿਕ ਇੰ ਪੁੱ ਟ/ਆਊਟਪੁੱ ਟ?

ANS: C++ I/O ਆਪਰੇਸ਼ਨ ਸਟ੍ਰੀਮ ਸੰ ਕਲਪ ਦੀ ਵਰਤੋਂ ਕਰ ਰਿਹਾ ਹੈ। ਸਟ੍ਰੀਮ ਬਾਈਟਸ ਜਾਂ ਡੇਟਾ
ਦੇ ਪ੍ਰਵਾਹ ਦਾ ਕ੍ਰਮ ਹੈ। ਇਹ ਪ੍ਰਦਰਸ਼ਨ ਨੂੰ ਤੇਜ਼ ਬਣਾਉਂਦਾ ਹੈ.

ਜੇਕਰ ਬਾਈਟਸ ਮੁੱ ਖ ਮੈਮੋਰੀ ਤੋਂ ਡਿਵਾਈਸ ਜਿਵੇਂ ਪ੍ਰਿੰ ਟਰ, ਡਿਸਪਲੇ ਸਕਰੀਨ, ਜਾਂ ਇੱ ਕ ਨੈ ਟਵਰਕ
ਕਨੈ ਕਸ਼ਨ ਆਦਿ ਵਿੱ ਚ ਵਹਿੰ ਦੇ ਹਨ, ਤਾਂ ਇਸਨੂੰ ਆਉਟਪੁੱ ਟ ਓਪਰੇਸ਼ਨ ਕਿਹਾ ਜਾਂਦਾ ਹੈ।

ਜੇਕਰ ਬਾਈਟਸ ਡਿਵਾਈਸ ਜਿਵੇਂ ਕਿ ਪ੍ਰਿੰ ਟਰ, ਡਿਸਪਲੇ ਸਕਰੀਨ, ਜਾਂ ਨੈ ਟਵਰਕ ਕਨੈ ਕਸ਼ਨ ਆਦਿ
ਤੋਂ ਮੁੱ ਖ ਮੈਮੋਰੀ ਵਿੱ ਚ ਵਹਿੰ ਦੇ ਹਨ, ਤਾਂ ਇਸਨੂੰ ਇਨਪੁਟ ਆਪਰੇਸ਼ਨ ਕਿਹਾ ਜਾਂਦਾ ਹੈ।

I/O Library Header Files

Header Function and Description


File

<iostream> It is used to define the cout, cin and cerr objects, which correspond to
standard output stream, standard input stream and standard error
stream, respectively.

<iomanip> It is used to declare services useful for performing formatted I/O, such
as setprecision and setw.

<fstream> It is used to declare services for user-controlled file processing.

Let us see the common header files used in C++ programming are:
Standard output stream (cout)

The cout is a predefined object of ostream class. It is connected with the


standard output device, which is usually a display screen. The cout is used in
conjunction with stream insertion operator (<<) to display the output on a
console

Standard input stream (cin)

The cin is a predefined object of istream class. It is connected with the


standard input device, which is usually a keyboard. The cin is used in
conjunction with stream extraction operator (>>) to read the input from a
console.

ਮਿਆਰੀ ਆਉਟਪੁੱ ਟ ਸਟ੍ਰੀਮ (ਕਾਉਟ)

ਕਾਉਟ ਓਸਟ੍ਰੀਮ ਕਲਾਸ ਦੀ ਇੱ ਕ ਪੂਰਵ-ਪ੍ਰਭਾਸ਼ਿਤ ਵਸਤੂ ਹੈ। ਇਹ ਸਟੈਂਡਰਡ ਆਉਟਪੁੱ ਟ


ਡਿਵਾਈਸ ਨਾਲ ਜੁੜਿਆ ਹੋਇਆ ਹੈ, ਜੋ ਕਿ ਆਮ ਤੌਰ 'ਤੇ ਡਿਸਪਲੇ ਸਕਰੀਨ ਹੁੰ ਦਾ ਹੈ। ਕੌਟ ਦੀ
ਵਰਤੋਂ ਕੰ ਸੋਲ 'ਤੇ ਆਉਟਪੁੱ ਟ ਨੂੰ ਪ੍ਰਦਰਸ਼ਿਤ ਕਰਨ ਲਈ ਸਟ੍ਰੀਮ ਸੰ ਮਿਲਨ ਆਪਰੇਟਰ (<<) ਦੇ
ਨਾਲ ਜੋੜ ਕੇ ਕੀਤੀ ਜਾਂਦੀ ਹੈ

ਸਟੈਂਡਰਡ ਇਨਪੁਟ ਸਟ੍ਰੀਮ (ਸੀਨ)

cin istream ਕਲਾਸ ਦੀ ਇੱ ਕ ਪੂਰਵ ਪਰਿਭਾਸ਼ਿਤ ਵਸਤੂ ਹੈ। ਇਹ ਸਟੈਂਡਰਡ ਇਨਪੁਟ ਡਿਵਾਈਸ
ਨਾਲ ਜੁੜਿਆ ਹੋਇਆ ਹੈ, ਜੋ ਕਿ ਆਮ ਤੌਰ 'ਤੇ ਕੀਬੋਰਡ ਹੁੰ ਦਾ ਹੈ। ਕੰ ਸੋਲ ਤੋਂ ਇਨਪੁਟ ਨੂੰ ਪੜ੍ਹਨ
ਲਈ ਸਿਨ ਦੀ ਵਰਤੋਂ ਸਟ੍ਰੀਮ ਐਕਸਟਰੈਕਸ਼ਨ ਆਪਰੇਟਰ (>>) ਦੇ ਨਾਲ ਕੀਤੀ ਜਾਂਦੀ ਹੈ।

Let's see the simple example of standard input stream (cin):

1. #include <iostream>
2. using namespace std;
3. int main( ) {
4. int age;
5. cout << "Enter your age: ";
6. cin >> age;
7. cout << "Your age is: " << age << endl;
8. }

Q.8
Difference between procedural programming and object-oriented
programming?

S.no On the Procedural Programming Object-oriented programming


. basis of

1. Definition It is a programming Object-oriented programming is a


language that is derived computer programming design
from structure programming philosophy or methodology that
and based upon the concept organizes/ models software design
of calling procedures. It around data or objects rather than
follows a step-by-step functions and logic.
approach in order to break
down a task into a set of
variables and routines via a
sequence of instructions.

2. Security It is less secure than OOPs. Data hiding is possible in object-


oriented programming due to
abstraction. So, it is more secure
than procedural programming.

3. Approach It follows a top-down It follows a bottom-up approach.


approach.

4. Data In procedural programming, In OOP, objects can move and


movement data moves freely within the communicate with each other via
system from one function to member functions.
another.

5. Orientation It is structure/procedure- It is object-oriented.


oriented.

6. Access There are no access The access modifiers in OOP are


modifiers modifiers in procedural named as private, public, and
programming. protected.

7. Inheritance Procedural programming There is a feature of inheritance in


does not have the concept object-oriented programming.
of inheritance.

8. Code There is no code reusability It offers code reusability by using


reusability present in procedural the feature of inheritance.
programming.
9. Overloading Overloading is not possible In OOP, there is a concept of
in procedural programming. function overloading and operator
overloading.

10. Importance It gives importance to It gives importance to data over


functions over data. functions.

11. Virtual class In procedural programming, In OOP, there is an appearance of


there are no virtual classes. virtual classes in inheritance.

12. Complex It is not appropriate for It is appropriate for complex


problems complex problems. problems.

13. Data hiding There is not any proper way There is a possibility of data
for data hiding. hiding.

14. Program In Procedural programming, In OOP, a program is divided into


division a program is divided into small parts that are referred to as
small programs that are objects.
referred to as functions.

15. Examples Examples of Procedural The examples of object-oriented


programming include C, programming are -
Fortran, Pascal, and VB. .NET, C#, Python, Java, VB.NET,
and C++.

S.no. On the Procedural Programming Object-oriented programming


basis of

1. . ਪਰਿਭਾਸ਼ਾ ਇਹ ਇੱ ਕ ਪ੍ਰੋਗ੍ਰਾਮਿੰ ਗ ਭਾਸ਼ਾ ਹੈ ਜੋ ਆਬਜੈਕਟ-ਓਰੀਐਂਟਡ ਪ੍ਰੋਗਰਾਮਿੰ ਗ


ਸਟ੍ਰਕਚਰ ਪ੍ਰੋਗ੍ਰਾਮਿੰ ਗ ਤੋਂ ਲਿਆ ਇੱ ਕ ਕੰ ਪਿਊਟਰ ਪ੍ਰੋਗ੍ਰਾਮਿੰ ਗ ਡਿਜ਼ਾਇਨ
ਗਿਆ ਹੈ ਅਤੇ ਕਾਲਿੰ ਗ ਦਰਸ਼ਨ ਜਾਂ ਕਾਰਜਪ੍ਰਣਾਲੀ ਹੈ ਜੋ
ਪ੍ਰਕਿਰਿਆਵਾਂ ਦੇ ਸੰ ਕਲਪ 'ਤੇ ਫੰ ਕਸ਼ਨਾਂ ਅਤੇ ਤਰਕ ਦੀ ਬਜਾਏ ਡੇਟਾ
ਅਧਾਰਤ ਹੈ। ਇਹ ਨਿਰਦੇਸ਼ਾਂ ਦੇ ਜਾਂ ਵਸਤੂਆਂ ਦੇ ਆਲੇ ਦੁਆਲੇ
ਕ੍ਰਮ ਦੁਆਰਾ ਵੇਰੀਏਬਲ ਅਤੇ ਸੌਫਟਵੇਅਰ ਡਿਜ਼ਾਈਨ ਨੂੰ
ਰੁਟੀਨ ਦੇ ਇੱ ਕ ਸਮੂਹ ਵਿੱ ਚ ਇੱ ਕ ਸੰ ਗਠਿਤ/ਮਾਡਲ ਕਰਦੀ ਹੈ।
ਕਾਰਜ ਨੂੰ ਤੋੜਨ ਲਈ ਇੱ ਕ
ਕਦਮ-ਦਰ-ਕਦਮ ਪਹੁੰ ਚ ਦੀ
ਪਾਲਣਾ ਕਰਦਾ ਹੈ।

2 ਸੁਰੱ ਖਿਆ ਇਹ OOPs ਨਾਲੋਂ ਘੱ ਟ . ਐਬਸਟਰੈਕਸ਼ਨ ਦੇ ਕਾਰਨ ਆਬਜੈਕਟ-


ਸੁਰੱ ਖਿਅਤ ਹੈ। ਓਰੀਐਂਟੇਡ ਪ੍ਰੋਗਰਾਮਿੰ ਗ ਵਿੱ ਚ ਡੇਟਾ ਨੂੰ
ਛੁਪਾਉਣਾ ਸੰ ਭਵ ਹੈ। ਇਸ ਲਈ, ਇਹ
ਪ੍ਰਕਿਰਿਆਤਮਕ ਪ੍ਰੋਗਰਾਮਿੰ ਗ ਨਾਲੋਂ
ਵਧੇਰੇ ਸੁਰੱ ਖਿਅਤ ਹੈ.

3 . ਦ੍ਰਿਸ਼ਟੀਕੋਣ ਇਹ ਇੱ ਕ ਉੱਪਰ ਤੋਂ ਹੇਠਾਂ ਪਹੁੰ ਚ ਇਹ ਇੱ ਕ ਤਲ-ਅੱ ਪ ਪਹੁੰ ਚ ਦੀ ਪਾਲਣਾ


ਦੀ ਪਾਲਣਾ ਕਰਦਾ ਹੈ। ਕਰਦਾ ਹੈ.

4 ਡੇਟਾ ਮੂਵਮੈਂਟ ਪ੍ਰਕਿਰਿਆਤਮਕ OOP ਵਿੱ ਚ, ਆਬਜੈਕਟ ਸਦੱ ਸ ਫੰ ਕਸ਼ਨਾਂ


ਪ੍ਰੋਗਰਾਮਿੰ ਗ ਵਿੱ ਚ, ਡੇਟਾ ਇੱ ਕ ਰਾਹੀਂ ਇੱ ਕ ਦੂਜੇ ਨਾਲ ਮੂਵ ਅਤੇ ਸੰ ਚਾਰ
ਫੰ ਕਸ਼ਨ ਤੋਂ ਦੂਜੇ ਫੰ ਕਸ਼ਨ ਵਿੱ ਚ ਕਰ ਸਕਦੇ ਹਨ
ਸਿਸਟਮ ਦੇ ਅੰ ਦਰ ਸੁਤੰ ਤਰ ਰੂਪ
ਵਿੱ ਚ ਚਲਦਾ ਹੈ।

5 ਸਥਿਤੀ ਇਹ ਬਣਤਰ/ਪ੍ਰਕਿਰਿਆ- ਇਹ ਵਸਤੂ-ਮੁਖੀ ਹੈ।


ਅਧਾਰਿਤ ਹੈ।

6 ਐਕਸੈਸ ਮੋਡੀਫਾਇਰ ਪਰੋਸੀਜਰਲ OOP ਵਿੱ ਚ ਪਹੁੰ ਚ ਸੰ ਸ਼ੋਧਕਾਂ ਨੂੰ ਪ੍ਰਾਈਵੇਟ,


ਪ੍ਰੋਗਰਾਮਿੰ ਗ ਵਿੱ ਚ ਕੋਈ ਐਕਸੈਸ ਜਨਤਕ ਅਤੇ ਸੁਰੱ ਖਿਅਤ ਨਾਮ ਦਿੱ ਤਾ
ਮੋਡੀਫਾਇਰ ਨਹੀਂ ਹਨ। ਗਿਆ ਹੈ।

7 . ਵਿਰਾਸਤ ਪ੍ਰਕਿਰਿਆ ਪ੍ਰੋਗ੍ਰਾਮਿੰ ਗ ਵਿੱ ਚ ਆਬਜੈਕਟ-ਓਰੀਐਂਟੇਡ ਪ੍ਰੋਗਰਾਮਿੰ ਗ


ਵਿਰਾਸਤ ਦੀ ਧਾਰਨਾ ਨਹੀਂ ਹੈ। ਵਿੱ ਚ ਵਿਰਾਸਤ ਦੀ ਵਿਸ਼ੇਸ਼ਤਾ ਹੈ।

8 . ਕੋਡ ਦੀ ਮੁੜ ਪ੍ਰਕਿਰਿਆ ਸੰ ਬੰ ਧੀ ਪ੍ਰੋਗਰਾਮਿੰ ਗ ਇਹ ਵਿਰਾਸਤ ਦੀ ਵਿਸ਼ੇਸ਼ਤਾ ਦੀ ਵਰਤੋਂ


ਵਰਤੋਂਯੋਗਤਾ ਵਿੱ ਚ ਕੋਈ ਕੋਡ ਮੁੜ ਵਰਤੋਂਯੋਗਤਾ ਕਰਕੇ ਕੋਡ ਦੀ ਮੁੜ ਵਰਤੋਂਯੋਗਤਾ ਦੀ
ਮੌਜੂਦ ਨਹੀਂ ਹੈ। ਪੇਸ਼ਕਸ਼ ਕਰਦਾ ਹੈ।

9 ਓਵਰਲੋਡਿੰ ਗ ਪ੍ਰਕਿਰਿਆਤਮਕ ਪ੍ਰੋਗਰਾਮਿੰ ਗ OOP ਵਿੱ ਚ, ਫੰ ਕਸ਼ਨ ਓਵਰਲੋਡਿੰ ਗ ਅਤੇ


ਵਿੱ ਚ ਓਵਰਲੋਡਿੰ ਗ ਸੰ ਭਵ ਨਹੀਂ ਓਪਰੇਟਰ ਓਵਰਲੋਡਿੰ ਗ ਦੀ ਇੱ ਕ
ਹੈ। ਧਾਰਨਾ ਹੈ।
10 ਮਹੱ ਤਵ ਇਹ ਡੇਟਾ ਉੱਤੇ ਫੰ ਕਸ਼ਨਾਂ ਨੂੰ ਇਹ ਫੰ ਕਸ਼ਨਾਂ ਨਾਲੋਂ ਡੇਟਾ ਨੂੰ ਮਹੱ ਤਵ
ਮਹੱ ਤਵ ਦਿੰ ਦਾ ਹੈ। ਦਿੰ ਦਾ ਹੈ।

11 ਵਰਚੁਅਲ ਪ੍ਰੋਸੀਜਰਲ ਪ੍ਰੋਗਰਾਮਿੰ ਗ ਵਿੱ ਚ, OOP ਵਿੱ ਚ, ਵਿਰਾਸਤ ਵਿੱ ਚ ਵਰਚੁਅਲ


ਕਲਾਸ ਕੋਈ ਵਰਚੁਅਲ ਕਲਾਸਾਂ ਨਹੀਂ ਕਲਾਸਾਂ ਦੀ ਦਿੱ ਖ ਹੈ।
ਹਨ।

12 ਗੁੰ ਝਲਦਾਰ . ਇਹ ਗੁੰ ਝਲਦਾਰ ਸਮੱ ਸਿਆਵਾਂ ਇਹ ਗੁੰ ਝਲਦਾਰ ਸਮੱ ਸਿਆਵਾਂ ਲਈ
ਸਮੱ ਸਿਆਵਾਂ ਲਈ ਉਚਿਤ ਨਹੀਂ ਹੈ। ਢੁਕਵਾਂ ਹੈ.

13 ਡਾਟਾ ਡਾਟਾ ਛੁਪਾਉਣ ਦਾ ਕੋਈ ਸਹੀ ਡਾਟਾ ਲੁਕਾਏ ਜਾਣ ਦੀ ਸੰ ਭਾਵਨਾ ਹੈ


ਛੁਪਾਉਣਾ ਤਰੀਕਾ ਨਹੀਂ ਹੈ।

14 ਪ੍ਰੋਗ੍ਰਾਮ ਪ੍ਰੋਸੀਜਰਲ ਪ੍ਰੋਗਰਾਮਿੰ ਗ ਵਿੱ ਚ, OOP ਵਿੱ ਚ, ਇੱ ਕ ਪ੍ਰੋਗਰਾਮ ਨੂੰ ਛੋਟੇ


ਡਿਵੀਜ਼ਨ ਇੱ ਕ ਪ੍ਰੋਗਰਾਮ ਨੂੰ ਛੋਟੇ ਪ੍ਰੋਗਰਾਮਾਂ ਹਿੱ ਸਿਆਂ ਵਿੱ ਚ ਵੰ ਡਿਆ ਜਾਂਦਾ ਹੈ ਜਿਨ੍ਹਾਂ
ਵਿੱ ਚ ਵੰ ਡਿਆ ਜਾਂਦਾ ਹੈ ਜਿਨ੍ਹਾਂ ਨੂੰ ਨੂੰ ਆਬਜੈਕਟ ਕਿਹਾ ਜਾਂਦਾ ਹੈ।
ਫੰ ਕਸ਼ਨ ਕਿਹਾ ਜਾਂਦਾ ਹੈ।

15 ਉਦਾਹਰਨਾਂ ਪ੍ਰੋਸੀਜਰਲ ਪ੍ਰੋਗਰਾਮਿੰ ਗ ਦੀਆਂ ਆਬਜੈਕਟ-ਅਧਾਰਿਤ ਪ੍ਰੋਗਰਾਮਿੰ ਗ


ਉਦਾਹਰਨਾਂ ਵਿੱ ਚ C, Fortran, ਦੀਆਂ ਉਦਾਹਰਣਾਂ ਹਨ -
Pascal, ਅਤੇ VB ਸ਼ਾਮਲ ਹਨ।
.NET, C#, Python, Java, VB.NET,
ਅਤੇ C++।

16

Q.9 What is FlowChart?

A flowchart is a type of diagram that represents a workflow or process. A


flowchart can also be defined as a diagrammatic representation of an
algorithm, a step-by-step approach to solving a task.
Flowchart symbols
Different types of boxes are used to make flowcharts flowchart Symbols. All
the different kinds of boxes are connected by arrow lines. Arrow lines are
used to display the flow of control. Let’s learn about each box in detail.
ਇੱ ਕ ਫਲੋਚਾਰਟ ਇੱ ਕ ਕਿਸਮ ਦਾ ਚਿੱ ਤਰ ਹੈ ਜੋ ਇੱ ਕ ਵਰਕਫਲੋ ਜਾਂ ਪ੍ਰਕਿਰਿਆ ਨੂੰ ਦਰਸਾਉਂਦਾ
ਹੈ। ਇੱ ਕ ਫਲੋਚਾਰਟ ਨੂੰ ਇੱ ਕ ਐਲਗੋਰਿਦਮ ਦੀ ਇੱ ਕ ਰੇਖਾ-ਚਿੱ ਤਰ ਪ੍ਰਤੀਨਿਧਤਾ ਵਜੋਂ ਵੀ
ਪਰਿਭਾਸ਼ਿਤ ਕੀਤਾ ਜਾ ਸਕਦਾ ਹੈ, ਇੱ ਕ ਕਾਰਜ ਨੂੰ ਹੱ ਲ ਕਰਨ ਲਈ ਇੱ ਕ ਕਦਮ-ਦਰ-ਕਦਮ
ਪਹੁੰ ਚ।

ਫਲੋਚਾਰਟ ਚਿੰ ਨ੍ਹ

ਫਲੋਚਾਰਟ ਫਲੋਚਾਰਟ ਚਿੰ ਨ੍ਹ ਬਣਾਉਣ ਲਈ ਵੱ ਖ-ਵੱ ਖ ਕਿਸਮਾਂ ਦੇ ਬਕਸੇ ਵਰਤੇ ਜਾਂਦੇ ਹਨ। ਸਾਰੇ
ਵੱ ਖ-ਵੱ ਖ ਕਿਸਮਾਂ ਦੇ ਬਕਸੇ ਤੀਰ ਰੇਖਾਵਾਂ ਦੁਆਰਾ ਜੁੜੇ ਹੋਏ ਹਨ। ਨਿਯੰ ਤਰਣ ਦੇ ਪ੍ਰਵਾਹ ਨੂੰ
ਪ੍ਰਦਰਸ਼ਿਤ ਕਰਨ ਲਈ ਐਰੋ ਲਾਈਨਾਂ ਦੀ ਵਰਤੋਂ ਕੀਤੀ ਜਾਂਦੀ ਹੈ। ਆਉ ਹਰ ਇੱ ਕ ਡੱ ਬੇ ਬਾਰੇ
ਵਿਸਥਾਰ ਵਿੱ ਚ ਜਾਣੀਏ।

Symbol Representation
Symbol Name

Terminal/Terminator

Process

Decision
Symbol Representation
Symbol Name

Document

Data or Input/Output

Stored Data

Flow Arrow

Comment or Annotation
Symbol Representation
Symbol Name

Predefined process

On-page connector/reference

Off-page connector/reference

You might also like