0% found this document useful (0 votes)
6 views

IT2_Sem-1_Lectures_APL (C++)_2023-2024

The document outlines the curriculum for an Advanced Programming Language (C++) course at the Lebanese French University for the 2023-2024 semester, covering fundamental concepts such as C++ syntax, program structure, and basic programming terms. It introduces C++ as a cross-platform, object-oriented language and details the processes for compiling and running C++ programs, as well as key programming elements like identifiers, constants, variables, and operators. Additionally, it discusses user-defined data types, including structures and enumerations, providing a comprehensive foundation for students in the field of programming.

Uploaded by

cnj59dbpzs
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

IT2_Sem-1_Lectures_APL (C++)_2023-2024

The document outlines the curriculum for an Advanced Programming Language (C++) course at the Lebanese French University for the 2023-2024 semester, covering fundamental concepts such as C++ syntax, program structure, and basic programming terms. It introduces C++ as a cross-platform, object-oriented language and details the processes for compiling and running C++ programs, as well as key programming elements like identifiers, constants, variables, and operators. Additionally, it discusses user-defined data types, including structures and enumerations, providing a comprehensive foundation for students in the field of programming.

Uploaded by

cnj59dbpzs
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 115

Lebanese French University

College of Engineering and Computer Science


Department of Information Technology
First Semester
2023 - 2024

Asst. Prof. Ashish Sharma


[email protected]

ADVANCE PROGRAMMING LANGUAGE (C++)


Lecture 1
Outlines
• Introduction about Programming Language: C++

• Purpose of Using C++

• Basic Program Structure of C++

• Compile and Run (Execute) Processes of a C++ Program

• To Understand C++ Syntax

• C++ Output (Print Text)

Advance Programming Language (C++) | Department of IT | Stage-2 Sem-1 10/5/2023 2


Introduction about Programming Language: C++

▪ C++ is a cross-platform language that can be used to create


sophisticated high-performance applications.

▪ C++ was developed by Bjarne Stroustrup in 1979 at Bell labs in


Murray Hill, New Jersey.

▪ He initially called the new language "C with Classes." However, in


1983 the name was changed to C++.

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

▪ The language was updated 3 major times in 2011, 2014, and 2017 to
C++11, C++14, and C++17.

10/5/2023 3
Purpose of Using C++ OR Why Use C++?

▪ 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 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!

10/5/2023 4
Basic Program Structure of C++

Process of writing a C++ Program

Step 1: Write the source codes (.cpp) and header files (.h).

Step 2: Pre-process the source codes according to the preprocessor directives.


Preprocessor directives begin with a hash sign (#), e.g., #include and #define.

Step 3: Compile the pre-processed source codes into object codes (.obj, .o).

Step 4: Link the compiled object codes with other object codes and the library
object codes (.lib, .a) to produce the executable code (.exe).

Step 5: Load the executable code into computer memory.

Step 6: Run the executable code, with the input to produce the desired output.
10/5/2023 5
Figure: Compile and Run (Execute) Processes of a C++ Program
10/5/2023 6
To Understand C++ Syntax
To break up the following code to understand it better:

#include <iostream>
using namespace std;

int main() {
cout << "Hello World!";
return 0;
}
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 the programmer can use names for
objects and variables from the standard library.
10/5/2023 7
Line 3: A blank line. C++ ignores white space.

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 } to actually end the main
function.
10/5/2023 8
Omitting Namespace

Some of C++ programs that runs without the standard namespace library. The
using namespace std line can be omitted and replaced with the std keyword,
followed by the Scope Resolution Operator (::) operator for some objects:

#include <iostream>

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

10/5/2023 9
C++ Output (Print Text)

The cout object, together with the << Programmer can add as many cout
operator, is used to output values/print objects as per need.
text:
#include <iostream>
#include <iostream> using namespace std;
using namespace std;
int main() {
int main() { cout << "Hello World!";
cout << "Hello World!"; cout << "I am learning C++";
return 0; return 0;
} }

10/5/2023 10
Thanks
Any Question
?
Advance Programming Language (C++) | Department of IT | Stage-2 Sem-1 10/5/2023 11
Lebanese French University

College of Engineering and Computer Science


Department of Information technology
First Semester
2023 - 2024

Asst. Prof. Ashish Sharma


[email protected]

ADVANCE PROGRAMMING LANGUAGE (C++)


Lecture 2
Outlines
• Basic Terms to understand a C++ Program
➢ Identifier
➢ Constant
➢ Preprocessor definitions (#define)
➢ Variable
➢ Keywords
➢ Statements
➢ Comments

Advance Programming Language (C++) | Department of IT | Stage-2 Sem-1 10/5/2023 13


Identifiers
• A C++ identifier is a name used to identify a variable, function, class,
module, or any other user-defined item.

• An identifier starts with a letter A to Z or a to z or an underscore ( _ )


followed by zero or more letters, underscores, and digits (0 to 9).

• C++ does not allow punctuation characters such as @, $, and % within


identifiers.

• C++ is a case-sensitive programming language. Thus, Manpower


and manpower are two different identifiers in C++.

Some examples of acceptable identifiers:

mohd zara abc move_name a_123


myname50 _temp j a23b9 retVal
10/5/2023 14
Constant (const)
Constants refer to fixed values that the program cannot alter or change.

Constants can be of any of the basic data types like char, int, float, double,
etc. The way each constant is represented depends upon its type.

Constants are also called literals.

In C++, programmer can create variables for which value cannot be modify
or change. For this, programmer use the const keyword.
Example:
const int LIGHT_SPEED = 299792458;
LIGHT_SPEED = 2500 // Error! LIGHT_SPEED is a constant.

Here, programmer have used the keyword const to declare a constant named
LIGHT_SPEED. If anyone try to change the value of LIGHT_SPEED, will
get an error.
10/5/2023 15
Preprocessor definitions (#define)
Another mechanism to name constant values is the use of preprocessor
definitions. They have the following form:

#define identifier replacement

After this directive, any occurrence of identifier in the code is interpreted as


replacement, where replacement is any sequence of characters (until the end
of the line). This replacement is performed by the preprocessor, and happens
before the program is compiled, thus causing a sort of blind replacement: the
validity of the types or syntax involved is not checked in any way.

NOTE: The #define lines are preprocessor directives, and as such are single-
line instructions that -unlike C++ statements- do not require semicolons (;) at
the end; the directive extends automatically until the end of the line. If a
semicolon is included in the line, it is part of the replacement sequence and is
also included in all replaced occurrences.
10/5/2023 16
Programming Examples for
Constant (const) and Preprocessor definitions (#define)

#include <iostream> #include <iostream>


using namespace std; using namespace std;

const double pi = 3.14159; #define PI 3.14159


const char newline = '\n'; #define NEWLINE '\n'

int main () int main ()


{ {
double r=5.0; // radius double r=5.0; // radius
double circle; double circle;

circle = 2 * pi * r; circle = 2 * PI * r;
cout << circle; cout << circle;
cout << newline; cout << NEWLINE;
} }

10/5/2023 17
Variable

• 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.

The syntax to declare a variable:


type variable_list;

10/5/2023 18
The example of declaring variable is given below:
1.int x;
2.float y;
3.char z;
Here, x, y, z are variables and int, float, char are data types.

Programmer can also provide values while declaring the variables. This is known as definition of
variables, as given below:
1.int x=5, b=10; //declaring two (2) variables of integer type
2.float f=30.8;
3.char c='A';

NOTE: After assigning value to a variable and using a ‘const’ keyword, then the variable becomes
constant. 10/5/2023 19
Rules for defining variables

• A variable can have alphabets, digits and underscore.


• A variable name can start with alphabet and underscore only. It can't
start with digit.
• No white space is allowed within variable name.
• A variable name must not be any reserved word or keyword e.g. char,
float etc.

Valid variable names: Invalid variable names:


int a; int 4;
int _ab; int x y;
int a30; int double;

10/5/2023 20
Keywords
• A keyword is a reserved word. Keywords are predefined words.
• Keywords never use it as a variable name, constant name etc.

Total of 62 Keywords in C++ Language are given below.


auto break case char const continue default do
double else enum extern float for goto if
int long register return short signed sizeof static
struct switch typedef union unsigned void volatile while

asm dynamic_cast namespace reinterpret_cast bool typeid


explicit new static_cast false catch typename
operator template friend private class using
this inline public throw const_cast virtual
delete mutable protected true try wchar_t

10/5/2023 21
asm else new this
auto enum operator throw
bool explicit private true
break export protected try
case extern public typedef
catch false register typeid
char float reinterpret_cast typename
class for return union
const friend short unsigned
const_cast goto signed using
continue if sizeof virtual
default inline static void
delete int static_cast volatile
do long struct wchar_t
double mutable switch while
dynamic_cast namespace template
10/5/2023 22
Statement
In the most general sense, a statement is a part of our program that can be
executed. That is, a statement specifies an action.

A simple C++ statement is each of the individual instructions of a program,


like the variable declarations and expressions.

Statements are always end with a semicolon (;), and are executed in the
same order in which statements appear in a program.

In C++, statements categorize into these groups:


1. Selection
2. Iteration
3. Jump
4. Label
5. Expression
6. Block
10/5/2023 23
Types of Statements
1. In the selection statements are if and switch. (The term conditional
statement is often used in place of "selection statement.").

2. The iteration statements are while, for, and do-while. These are also
commonly called loop statements.

3. The jump statements are break, continue, goto and return.

4. The label statements include the case and default statements (discuss
along with the switch statement) and the label statement (discuss with
goto).

5. Expression statements are statements composed of a valid expression.

6. Block statements are simply blocks of code.


Remember, a block begins with Open Curly Brace( { ) and ends with
Close Curly Brace ( } ).
Block statements are also referred to as compound statements.
10/5/2023 24
Comments in C++
Program comments are explanatory statements that programmer can
include in the C++ code. These comments help anyone for reading the
source code.
All programming languages allow for some form of comments.
All characters available inside any comment are ignored by C++ compiler.
Comments are not executed by the compiler, while running a C++ program.

C++ supports single-line and multiple-line comments.


1. Single-line Comment: A comment can also start with //, extending to the
end of the line.
2. Multiple-line Comment: C++ comments start with /* and end with */.

For example −
// This is a comment
/* C++ comments can also
* span multiple lines
*/ 10/5/2023 25
Thanks
Any Question
?
Advance Programming Language (C++) | Department of IT | Stage-2 Sem-1 10/5/2023 26
Lebanese French University

College of Engineering and Computer Science


Department of Information technology
First Semester
2023 - 2024

Asst. Prof. Ashish Sharma


[email protected]

ADVANCE PROGRAMMING LANGUAGE (C++)


Lecture 3
Outlines
• Operators
• Data types
• User-defined Data types
➢ Structure
➢ Enumeration

Advance Programming Language (C++) | Department of IT | Stage-2 Sem-1 10/5/2023 28


Operators
An operator is simply a symbol that is used to perform operations.
Operators are symbols that perform operations on variables and values.
The different types of operators in C++, such as:

General Operator Type


+, -, *, /, % Arithmetic Operators
<, <=, >, >=, ==, != Relational Operators
Binary Operators &&, || Logical Operators
&, |, <<, >>, ~, ^ Bitwise Operators
=, +=, -=, *=, /=, %= Assignment Operators
Increment and Decrement
++, --, -, sizeof(Data_Type)
Unary Operators Operators
! Logical Operator
Ternary Operator ?: Conditional Operator
10/5/2023 29
Data Types
A data type specifies the type of data that a variable can store such as
integer, floating, character etc.
Also, it specifies the amount of memory consumed by the variable to the
system.

There are four types of data types in C++ language.

Types Data Types


Basic (or Primitive) int, char, float, double,
Data Type etc
Derived Data Type array, pointer, etc
Enumeration Data Type enum

User Defined Data Type structure

10/5/2023 30
Structure in C++
A structure is a user-defined datatype which is a collection of simple
variables. The variables in a structure can be of different types: Some can be int,
some can be float, and so on.
The data items in a structure are called the members of the structure.
The keyword struct introduces the structure definition.
Here it is:

struct part
{
int modelnumber;
int partnumber;
float cost;
};

Syntax of the structure definition. 10/5/2023 31


Defining a Structure Variable in C++
The first statement in main( )
part part1;
defines a variable, called part1, of type structure part.
This definition reserves space in memory for part1.

How much space?


It holds enough space for all
the members of part1—
namely modelnumber,
partnumber, and cost.

In this case, part1 consumes


memory space 4 bytes for
each of the two ints
(assuming a 32-bit system),
and 4 bytes for the float.

Structure members in memory. 10/5/2023 32


//Example: Implementation of Structure in C++
Here, to start with a structure that contains three variables: two integers and a
floating-point number.
This structure represents an item in a widget company’s parts inventory. The
structure is a kind of blueprint specifying what information is necessary for a
single part. int main( )
{
#include <iostream> part part1; //define a structure variable
using namespace std;
//give values to structure members
struct part //declare a structure part1.modelnumber = 6244;
{ part1.partnumber = 373;
//ID number of widget part1.cost = 217.55F;
int modelnumber; //display structure members
//ID number of widget part cout << “Model “ << part1.modelnumber;
int partnumber; cout << “, part “ << part1.partnumber;
cout << “, costs $” << part1.cost << endl;
//cost of part
float cost; return 0;
}; }
OUTPUT 10/5/2023 33
Model 6244, part 373, costs $217.55
Enumerations in C++
An enumeration is a user-defined type or programmer-defined type that is
limited to a fixed list of values. It consists of a set of named integral constants
that are known as enumerators.
By default, the first value is assigned 0, the next one is assigned 1, and so on, but
programmer can explicitly (or manually) set the value of an enumerator.

An enum declaration defines


the set of all names that will be
permissible values of the type.

These permissible values are


called enumerators. The enum
type days_of_week has seven
enumerators: Sun, Mon, Tue,
and so on, up to Sat.

Syntax of enum specifier.


10/5/2023 34
//Example: An enumeration for the days of the week in C++
#include <iostream>
using namespace std;

//specify enum type


enum days_of_week { Sun, Mon, Tue, Wed, Thu, Fri, Sat };

int main( )
{ //can do comparisons
//define variables of type days_of_week if(day1 < day2)
days_of_week day1, day2; cout << “day1 comes before day2\n”;
day1 = Mon; //give values to return 0;
day2 = Thu; //variables }

//can do integer arithmetic


int diff = day2 - day1;
cout << “Days between = “ << diff << endl;

OUTPUT
Days between = 3
10/5/2023 35
day1 comes before day2
Thanks
Any Question
?
Advance Programming Language (C++) | Department of IT | Stage-2 Sem-1 10/5/2023 36
Lebanese French University

College of Engineering and Computer Science


Department of Information technology
First Semester
2023 - 2024

Asst. Prof. Ashish Sharma


[email protected]

ADVANCE PROGRAMMING LANGUAGE (C++)


Lecture 4-5-6
Outlines
• Comma Operator ( , )
• Jump Statement (break, continue, goto, return)
• Library Function exit( )
• Selection Statement (switch-case-default)

Advance Programming Language (C++) | Department of IT | Stage-2 Sem-1 10/5/2023 38


Comma Operator ( , )

The comma operator ( , ) is an expression separator, it serves to separate


more than one expression, where only one expression is generally
expected.

// Programmer wanted to initialize more than one variable in loop


for ( n=0, i=100 ; n!=i ; n++, i-- )
{
// Whatever Source Code to execute by Compiler here...
}

Here n starts with a value of 0, and i with 100, the condition is n!=i (that
n is not equal to i). Because n is increased by one and i is decreased by
one, so that the loop's condition will become false after the 50th loop,
when both n and i will be equal to 50.

10/5/2023 39
The break Statement
Using break, programmer can leave a loop in between, even condition to its
end, is not fulfilled. It can be used to end an infinite loop, or to force it to
end, before its natural end.

//To stop the count down before its natural end, using break
#include <iostream>
using namespace std;
int main () { OUTPUT
int n;
for (n=10; n>0; n--) { 10, 9, 8, 7, 6, 5, 4, 3, countdown aborted!
cout << n << ", ";
if (n= =3){
cout << "countdown aborted!";
break;
}
}
return 0;
} 10/5/2023 40
//Example: To demonstrate break statement using while loop.
#include <iostream>
using namespace std;
int main( ){
int num = 10;
while(num <= 200) {
cout<<"Value of num is: "<<num<<endl;
if (num = = 12) {
break;
}
num++;
}
cout<<"Hey, I'm out of the loop";
return 0;
}
10/5/2023 41
The continue Statement
The continue statement causes the program to skip the rest of the loop in the
current iteration, as if the end of the statement block has been reached,
causing it to jump to the start of the following iteration.

//To skip the number 5 in our countdown using continue


#include <iostream>
using namespace std;
int main ()
{
for (int n=10; n>0; n--)
{
if (n = = 5) continue;
cout << n << ", ";
}
OUTPUT
cout << "FIRE!\n";
return 0; 10, 9, 8, 7, 6, 4, 3, 2, 1, FIRE!
} 10/5/2023 42
//Example: To demonstrate continue statement using while loop.

#include <iostream>
using namespace std;
int main(){
int j = 6;
while (j >= 0) {
if (j = = 4) {
j--;
continue;
}
cout<<"Value of j: "<<j<<endl;
j--;
}
return 0;
} 10/5/2023 43
//Example: To demonstrate continue statement using do-while loop.
#include <iostream>
using namespace std;
int main( ){
int j = 4;
do {
if (j = = 7) {
j++;
continue;
}
cout<<"j is: "<<j<<endl;
j++;
}while(j < 10);
return 0;
}
10/5/2023 44
The goto Statement
goto allows to make an absolute jump //Countdown loop using goto
to another point in the program. #include <iostream>
using namespace std;
Programmer should use this feature int main ()
with caution, since its execution causes {
an unconditional jump ignoring any int n=10;
type of nesting limitations. loop:
cout << n << ", ";
The destination point is identified by a n--;
label, which is then used as an if (n>0)
argument for the goto statement. goto loop;
cout << "FIRE!\n";
A label is made of a valid identifier return 0;
followed by a colon (:). }
OUTPUT
10, 9, 8, 7, 6, 5, 4, 3, 2, 1, FIRE!
10/5/2023 45
/*Example: To demonstrate goto statement to check whether the input
number is even or odd.*/
#include <iostream>
using namespace std;
int main(){
int num;
cout<<"Enter a number: ";
cin>>num;
if (num % 2==0){
goto print;
}
else {
cout<<"Odd Number";
}

print:
cout<<"Even Number";
return 0;
} 10/5/2023 46
Library Function exit( )
exit is a function defined in the stdlib library. This function causes the
program to terminate, no matter where it is in the listing in the program. It
has no return value.

The purpose of exit is to terminate the current program with a specific exit
code. Its prototype is:

void exit (int exitcode);

The exitcode identifier is used by some operating systems and may be used
by calling programs.

By convention, an exit code of 0 means that the program finished normally


and any other value means that some error or unexpected results happened.

10/5/2023 47
//Example: To check Prime Number or not by demonstrating exit( ) function..
# include <iostream> OUTPUT
using namespace std;
Enter a number: 13
#include <stdlib.h> //for exit( ) It’s prime
int main( ) Enter a number: 22229
It’s prime
{
Enter a number: 22231
unsigned long n, j; It’s not prime; divisible by 11
cout << “Enter a number: “;
cin >> n; //get number to test
for(j=2; j <= n/2; j++) //divide by every integer from
if(n%j == 0) //2 on up; if remainder is 0,
{ //it’s divisible by j
cout << “It’s not prime; divisible by “ << j << endl;
exit(0); //exit from the program
}
cout << “It’s prime\n”;
return 0;
}
10/5/2023 48
The Selection Statement (switch)
The syntax of the switch statement is a bit peculiar. Its objective is to check several
possible constant values for an expression. It is a wonderful concept for Menu-driven
Programming approach.
It works in the following way: switch evaluates
switch (expression) expression and checks if it is equivalent to constant1,
{
if it is, it executes group of statements 1 until it finds
case constant1: the break statement.
group of statements 1;
break; When it finds this break statement, the program
jumps to the end of the switch selective structure.
case constant2:
group of statements 2;
If expression was not equal to constant1, it will be
break; checking against constant2. If it is equal to this, it
will execute group of statements 2 until a break
…………………………..
keyword is found, and then will jump to the end of the
…………………………..
switch selective structure.
default : Finally, if the value of expression did not match any
default group of statements
of the previously specified constants, the program will
}
execute the statements included after the default:
10/5/2023 49
label, if it exists (since it is optional).
10/5/2023 50
//Example: Simple Calculator using switch with break statement.
# include <iostream>
using namespace std;
int main()
{
char op;
float num1, num2;
cout << "Enter operator either + or - or * or / : ";
cin >> op;
cout << "Enter two operands: "; case '*':
cout << num1*num2;
cin >> num1 >> num2;
break;
switch(op)
{ case '/':
case '+': cout << num1/num2;
cout << num1+num2; break;
break; default:
case '-': cout << "Error! operator is not correct";
cout << num1-num2; break;
break; }
return 0;
} 10/5/2023 51
Both of the following source-code fragments have the same behavior:

if (x = = 1)
switch (x)
{
{
cout << "x is 1";
case 1:
}
cout << "x is 1";
break;
else if (x = = 2)
{
case 2:
cout << "x is 2";
cout << "x is 2";
}
break;
else
default:
{
cout << "value of x unknown";
cout << "value of x unknown";
}
}

10/5/2023 52
Thanks
Any Question
?
Advance Programming Language (C++) | Department of IT | Stage-2 Sem-1 10/5/2023 53
Lebanese French University

College of Engineering and Computer Science


Department of Information technology
First Semester
2023 - 2024

Asst. Prof. Ashish Sharma


[email protected]

ADVANCE PROGRAMMING LANGUAGE (C++)


Lecture 7-8
Outlines
• Functions Or Member Functions Or Modules (Or Method Or Procedure Or Subroutine) in C++
• Types of Functions
➢ System-defined (or Library) Functions
➢ User-defined Functions
✓ Non-parameterized Functions
✓ Parameterized Functions
❖ Call by Value
❖ Call by Reference

Advance Programming Language (C++) | Department of IT | Stage-2 Sem-1 10/5/2023 55


Functions Or Member Functions
The function is block of code, which is used for a specific or particular
task, is also known as procedure or subroutine in other programming
languages.
To perform any task, programmer can creates function. A function can be
called many times.
It provides modularity and code reusability.

Two types of Functions:

1. System-defined (or Library)


Functions: are the functions which are
declared in the C++ header files such as
ceil(x), cos(x), exp(x), getch(), gets(), etc.

2. User-defined Functions: are the


functions which are created by the C++
programmer, so that he/she can use it
many times. It reduces complexity of a
big program and optimizes the code.
10/5/2023 56
Declaration and Definition of a Function

The syntax of creating function in C++ language is given


below:

//Function Declaration
return_type function_name(parameter_list);

//Function Definition
return_type function_name(data_type parameter...)
{
//code to be executed
}
10/5/2023 57
//Simple example of C++ function

#include <iostream>
NOTE: The static variable is initialized
using namespace std;
only once and exists till the end of a
program. It retains its value between
// Function Definition
multiple functions call.
void func() {
static int i=0; //static variable
The static variable has the default value
int j=0; //local variable
Zero (0) which is provided by compiler.
i++;
j++;
cout<<"i=" << i<<" and j=" <<j<<endl;

int main() //Function Definition


{ Output
func(); //Function Calling
i= 1 and j= 1
func(); //Function Calling i= 2 and j= 1
func(); //Function Calling i= 3 and j= 1
}
10/5/2023 58
Advantage of functions
There are many advantages of functions, such as:

1. Code Reusability: By creating functions in C++,


programmer can call it many times. So programmer does not
need to write the same code again and again.

2. Code optimization: It makes the code optimized,


programmer does not need to write much code.

10/5/2023 59
Call by value and Call by reference in C++
There are two ways to pass value or data to function in C++
language:
1. call by value
2. call by reference

Original value is not modified in call by value, but it is


modified in call by reference.
10/5/2023 60
Call by value in C++

In call by value, original value is not modified.

Here, value being passed to the function is locally stored by the function
parameter in stack memory location. It will not change the value of
variable inside the caller method such as main().

//Simple Example: Call by value


#include <iostream> //Function Definition
using namespace std; void change(int data)
{
void change(int data); //Function Declaration data = 5;
}
int main() //main() Block Function Definition
{
int data = 3; Output
change(data); //Calling Function
cout << "Value of the data is: " << data<< endl; Value of the data is: 3
return 0;
} 10/5/2023 61
Call by reference in C++
In call by reference, original value is modified because we pass reference (address).
Here, address of the value is passed in the function, so actual and formal
arguments share the same address space. Hence, value changed inside the
function, is reflected inside as well as outside the function.

#include<iostream> int main()


using namespace std; {
int x=500, y=100;
/*Function Declaration swap(&x, &y); // passing value to function
and Definition*/
void swap(int *x, int *y) cout<<"Value of x is: "<<x<<endl;
{ cout<<"Value of y is: "<<y<<endl;
int swap; return 0;
swap=*x; } Output:
*x=*y;
Value of x is: 100
*y=swap; Note: To understand the call by
Value of y is: 500
} reference, programmer must have the
basic knowledge of pointers. 10/5/2023 62
Difference between call by value and call by reference

S.
Call by value Call by reference
No.

A copy of value is passed to the An address of value is passed to


1
function the function
Changes made inside the Changes made inside the function
2 function is not reflected on is reflected outside the function
other functions also
Actual and formal arguments Actual and formal arguments will
3 will be created in different be created in same memory
memory location location

10/5/2023 63
Thanks
Any Question
?
Advance Programming Language (C++) | Department of IT | Stage-2 Sem-1 10/5/2023 64
Lebanese French University

College of Engineering and Computer Science


Department of Information technology
First Semester
2023 - 2024

Asst. Prof. Ashish Sharma


[email protected]

ADVANCE PROGRAMMING LANGUAGE (C++)


Lecture 9-10
Outlines
• Inline Function in C++
• Recursion
• Difference Between Recursion and Iteration

Advance Programming Language (C++) | Department of IT | Stage-2 Sem-1 10/5/2023 66


Inline Function in C++

C++ inline function is powerful concept that is commonly used with classes.
All the member functions defined inside the class definition are by
default declared as Inline.

If a function is inline, the compiler places a copy of the code of that function
at each point, where the function is called at compile time.

To inline a function, place the keyword inline before the function name and
define the function before any calls are made to the function.

The compiler can ignore the inline qualifier in case defined function is more
than a line.

A function definition in a class definition is an inline function definition,


even without the use of the inline specifier.

10/5/2023 67
Contd…

Any change to an inline function could require all clients of the function to
be recompiled because compiler would need to replace all the code once
again, otherwise it will continue with old functionality.

Inline functions are actual functions, which are copied everywhere during
compilation, so the overhead of function calling is reduced.

All the functions defined inside class definition are by default inline, but
programmer can also make any non-class function inline by using
keyword inline with them.

10/5/2023 68
The syntax for defining the function inline is:

inline return-type function-name(parameters)


{
// function code
}

Remember, inline function is only a request to the compiler, not a command.


Compiler can ignore the request for inline. Compiler may not perform inline
behavior in such circumstances like:
1. If a function contains a loop. (for, while, do-while)
2. If a function contains static variables.
3. If a function is recursive.
4. If a function return type is other than void, and the return statement
doesn’t exist in function body.
5. If a function contains switch or goto statement.
10/5/2023 69
For an inline function, declaration and definition must be done together.
For example,
inline void fun(int a)
{
return a++;
}
Some Important points about Inline Functions:
1. Programmer must keep inline functions small, small inline functions have better
efficiency.
2. Inline functions do increase efficiency, but programmer should not make all the
functions inline. Because if programmer make large functions inline, it may lead
to code bloat, and might affect the speed too.
3. Hence, it is advised to define large functions outside the class definition using
scope resolution :: operator, because if programmer define such functions inside
class definition, then they become inline automatically.
4. Inline functions are kept in the Symbol Table by the compiler, and all the call
for such functions is taken care at compile time. 10/5/2023 70
Following is an example, which makes use of inline function
to return maximum value of two numbers.
#include <iostream>
using namespace std;
inline int Max(int x, int y) { Output
return (x > y)? x : y;
Max (20,10): 20
} Max (0,200): 200
Max (100,1010): 1010
// Main function for the program
int main( ) {
cout << "Max (20,10): " << Max(20,10) << endl;
cout << "Max (0,200): " << Max(0,200) << endl;
cout << "Max (100,1010): " << Max(100,1010) << endl;
return 0;
}
10/5/2023 71
Recursion in C++
When a function is called within the same function, it is known as
recursion.

The function which calls the same function, is known as recursive


function.

A function that calls itself, and doesn't perform any task after function call,
is known as tail recursion.

In tail recursion, programmers generally call the same function with


return statement.

Syntax of Recursion
Recursion_function( )
{
Recursion_function( ); //calling self function
}
10/5/2023 72
/*Example:
To print factorial number using recursion in C++ language*/
#include<iostream> int factorial(int n)
using namespace std; {
int main() if(n < 0)
{ return(-1); /*Wrong value*/
int factorial(int);
int fact, value;
if(n = = 0)

cout<<"Enter any number: "; return(1); /*Terminating condition*/

cin>>value; else
fact = factorial(value);
{
cout<<"Factorial of a number is: "<<fact;
return (n * factorial(n-1));
cout<<endl;
}
return 0;
}
} OUTPUT
Enter any number: 5
Factorial of a number is: 120 10/5/2023 73
10/5/2023 74
Difference Between Recursion and Iteration
Recursion and iteration both repeatedly executes the set of instructions.

Recursion is when a statement in a function calls itself repeatedly.


Whereas, the iteration is when a loop repeatedly executes until the
controlling condition becomes false.

The primary difference between recursion and iteration, such as:


A recursion is a process always applied to a function.

The iteration is applied to the set of instructions which programmer wants


to get repeatedly executed.

10/5/2023 75
S.
Recursion Iteration
No.

Recursion is when a method repeatedly Iteration is when a set of instructions


1
calls itself in a program. are repeatedly executed in a program.

Iteration statements contain


A recursive method contains set of
initialization, increment, condition, set
2 instructions, statement calling itself,
of instruction within a loop and a
and a termination condition.
control variable.
Infinite recursion can lead to system
crash, due to high consumption of Infinite iteration consumes CPU
3
memory allocation to variables at cycles.
runtime.
Iteration is applied to set of
4 Recursion is always applied to method.
instruction.

Due to function calling overhead


5 Execution of iteration is faster.
execution of recursion is slower.

6 Recursion reduces the size of code. Iterations make a code longer.


10/5/2023 76
C++ Program to find factorial of a C++ Program to find factorial of a
number using recursion number using iteration
#include <iostream> #include <iostream>
using namespace std; using namespace std;
int factorial(int n) int main( )
{ {
if(n == 0) int i, n = 5, fac = 1;
return 1;
else
return n * factorial(n-1); for(i = 1; i <= n; ++i)
} fac = fac * i;

int main( )
cout<<"Factorial for 5 is “<<fac;
{
cout<<"Factorial for 5 is “<<factorial(5);
return 0;
return 0;
}
}

10/5/2023 77
Thanks
Any Question
?
Advance Programming Language (C++) | Department of IT | Stage-2 Sem-1 10/5/2023 78
Lebanese French University

College of Engineering and Computer Science


Department of Information technology
First Semester
2023 - 2024

Asst. Prof. Ashish Sharma


[email protected]

ADVANCE PROGRAMMING LANGUAGE (C++)


Lecture 11-12
Outlines
• Introduction to Arrays
• Types of Arrays
➢ Single Dimensional (1-D) Array
➢ Multi Dimensional (2-D, 3-D or More)

Advance Programming Language (C++) | Department of IT | Stage-2 Sem-1 10/5/2023 80


Introduction to Arrays
An array is a series of elements of the same type placed in contiguous
memory locations that can be individually referenced by adding an index to
a unique identifier.

An array is a collection of data that holds fixed number of values of same


type.
Declaration of an array in C++

dataType arrayName[arraySize];

For example,
float mark[5];

Here, programmer declared an array, mark, of floating-point type and size


five (5). Meaning, it can hold 5 floating-point values.
10/5/2023 81
Types of Arrays
There is two types of arrays in C++ programming language, such as:
1. Single Dimension Array (1-D Array)
2. Multi-dimensions Array (2-D or 3-D or 4-D so on Array)

Advantages of C++ Array


• Code Optimization (less code)
• Random Access
• Easy to traverse data
• Easy to manipulate data
• Easy to sort data etc.

Disadvantages of C++ Array


• Fixed size
10/5/2023 82
Single Dimensional (1-D) Array: To Access Elements of an Array…..

An array consists of one dimension only, is called 1-D array.


Programmer can access elements of an array by using indices.
Suppose Programmer declared an array mark as above.

The first element is mark[0], second element is mark[1] and so on.

Few key notes:


▪ Arrays have 0 as the first index not 1. In this example, mark[0] is the first
element.

▪ If the size of an array is n, to access the last element, (n-1) index is used.
In this example, mark[4] is the last element.

▪ Suppose the starting address of mark[0] is 2120d. Then, the next address,
mark[1], will be 2124d, address of mark[2] will be 2128d and so on. It's
because the size of float is 4 bytes. 10/5/2023 83
To initialize an array in C++ programming…..

It is possible to initialize an array during declaration.

For example,
Here,
int mark[5] = {19, 10, 8, 17, 9}; mark[0] is equal to 19
mark[1] is equal to 10
mark[2] is equal to 8
mark[3] is equal to 17
mark[4] is equal to 9

Another method to initialize array during declaration:

int mark[] = {19, 10, 8, 17, 9};

Array index starts from 0 (Zero) to (n-1), for total number of elements n in
an array.
Array is used to store only fixed set of elements. 10/5/2023 84
To insert and print an array elements….

int mark[5] = {19, 10, 8, 17, 9};

mark[3] = 9; // change 4th element to 9

cin >> mark[2]; // take input from the user and insert in third element

cin >> mark[i]; // take input from the user and insert in (i+1)th element

cout << mark[0]; // print first element of the array

cout >> mark[i-1]; // print ith element of the array

10/5/2023 85
/* C++ program to store and calculate the sum of 5 numbers
entered by the user using arrays.*/

#include <iostream> OUTPUT


using namespace std; Enter 5 numbers:
int main() 3
{ 4
int numbers[5], sum = 0; 5
4
cout << "Enter 5 numbers: “<<endl; 2
Sum = 18
for (int i = 0; i < 5; ++i)
{
cin >> numbers[i]; // Storing 5 number entered by user in an array
sum += numbers[i]; // Finding the sum of numbers entered
}

cout << “\nSum = " << sum << endl;


return 0;
}
10/5/2023 86
Point to be remember about an array Square Bracket [ ]

In C++, it is syntactically correct to exceed the valid range of indices for an


array. This can create problems, since accessing out-of-range elements do
not cause errors on compilation, but can cause errors on runtime.
At this point, it is important to be able to clearly distinguish between the
two uses that brackets [ ] have related to arrays.

They perform two different tasks:


1. To specify the size of an array when it is declared.
int mark[5]; // declaration of a new array
2. To specify indices for concrete array elements when it is accessed.
mark[2] = 75; // access to an element of the array.

Do not confuse these two possible uses of brackets [ ] with arrays.


10/5/2023 87
C++ Multidimensional Arrays

The multidimensional array is also known as rectangular array. It can be


two dimensional or three dimensional or more.
The data is stored in tabular form (row * column) which is also known as
matrix.

For example:
Int arr[2][2]; //declaration of 2D array
Int arr[3][3][3]; //declaration of 3D array

int A[3][4];

Column-0 Column-1 Column-2 Column-3


Row-0 A[0][0] A[0][1] A[0][2] A[0][3]
Row-1 A[1][0] A[1][1] A[1][2] A[1][3]
Row-2 A[2][0] A[2][1] A[2][2] A[2][3]

10/5/2023 88
For example:

int X[3][4];
Here, X is a two dimensional array. It can hold a maximum of 12 elements.

Three dimensional array also works in a similar way.

For example:
float x[2][4][3];
This array x can hold a maximum of 24 elements.

Programmer can think this example as:


Each of the 2 elements can hold 4 elements, which makes 8 elements and
each of those 8 elements can hold 3 elements. Hence, total number of
elements this array can hold is 24.
10/5/2023 89
Multidimensional Array Initialization

To initialize a multidimensional array in more than one way.

Initialization of two dimensional array


int test[2][3] = {2, 4, -5, 9, 0, 9};

Better way to initialize this array with same array elements as above.
int test[2][3] = { {2, 4, 5}, {9, 0, 0}};

Initialization of three dimensional array


int test[2][3][4] = {3, 4, 2, 3, 0, -3, 9, 11, 23, 12, 23, 2, 13, 4, 56, 3, 5, 9, 3, 5,
5, 1, 4, 9};

Better way to initialize this array with same elements as above.


int test[2][3][4] = {
{ {3, 4, 2, 3}, {0, -3, 9, 11}, {23, 12, 23, 2} },
{ {13, 4, 56, 3}, {5, 9, 3, 5}, {3, 1, 4, 9} }
};
10/5/2023 90
/* C++ Program to display all elements of an initialized two
dimensional array. */
#include <iostream>
using namespace std;
int main()
{
int test[3][2] = {{2, -5}, {4, 0}, {9, 1}};

// Accessing two dimensional array using nested for loops


for(int i = 0; i < 3; ++i)
{
for(int j = 0; j < 2; ++j)
{
cout<< "test[" << i << "][" << j << "] = " << test[i][j] << endl;
}
}
return 0;
}
10/5/2023 91
/* C++ Program to Store value entered by user in three dimensional
array and display it. */
#include <iostream>
using namespace std;

int main()
{
int test[2][3][2]; //This array can store upto 12 elements
cout << "Enter 12 values: \n";

for(int i = 0; i < 2; ++i) { // Inserting the values into the test array using 3 nested for loops.
for (int j = 0; j < 3; ++j) {
for(int k = 0; k < 2; ++k ) {
cin >> test[i][j][k];
}}}

cout<<"\nDisplaying Value stored:"<<endl;

for(int i = 0; i < 2; ++i) // Displaying the values with proper index.


{
for (int j = 0; j < 3; ++j)
{
for(int k = 0; k < 2; ++k)
{
cout << "test[" << i << "][" << j << "][" << k << "] = " << test[i][j][k] << endl;
}
}
}
return 0; 10/5/2023 92
}
Thanks
Any Question
?
Advance Programming Language (C++) | Department of IT | Stage-2 Sem-1 10/5/2023 93
Lebanese French University

College of Engineering and Computer Science


Department of Information technology
First Semester
2023 - 2024

Asst. Prof. Ashish Sharma


[email protected]

ADVANCE PROGRAMMING LANGUAGE (C++)


Lecture 13
Outlines
• Introduction to String
• Types of Strings
➢ C-strings (C-style Strings)
➢ Strings that are objects of string class
• The String Class in C++

Advance Programming Language (C++) | Department of IT | Stage-2 Sem-1 10/5/2023 95


Introduction to String
String is a collection of characters. It is also known as array of characters
including null character (‘\0’). There are two types of strings commonly
used in C++ programming language:
1. C-strings (C-style Strings)
2. Strings that are objects of string class (The Standard C++ Library string
class)

C-strings
In C programming, the collection of characters is stored in the form of
arrays, this is also supported in C++ programming. Hence it's called C-
strings.
C-strings are arrays of type char terminated with null character, that is, \0.
(ASCII value of null character is 0) 10/5/2023 96
To initialize or define a C-string:
char str[] = "C++";
In the above code, str is a string and it holds 4 characters.
Although, "C++" has 3 character, the null character ‘\0’ is added to the end
of the string automatically.

Alternative ways of defining a string


char str[4] = "C++";
char str[] = {'C','+','+','\0'};
char str[4] = {'C','+','+','\0'};
Like arrays, it is not necessary to use all the space allocated for the string.

For example:
char str[100] = "C++";
10/5/2023 97
Example: C++ String to read a word.
//C++ program to display a string entered by user.
#include <iostream> Output
using namespace std;
int main() Enter a string: C++
{ You entered: C++
char str[100];
Enter another string: Programming is fun.
cout << "Enter a string: "; You entered: Programming
cin >> str;
cout << "You entered: " << str << endl;
cout << "\nEnter another string: ";
cin >> str;
cout << "You entered: "<<str<<endl;
return 0;
}
NOTE: In this example, only "Programming" is displayed instead of "Programming
is fun". This is because the extraction operator >> considers a whitespace " " has a
terminating character.

10/5/2023 98
Example: C++ String to read a line of text
//C++ program to read and display an entire line entered by user.
#include <iostream>
using namespace std;
Output
int main()
{
Enter a string: Programming is fun.
char str[100];
You entered: Programming is fun.
cout << "Enter a string: ";
cin.get(str, 100);
cout << "You entered: " << str << endl;
return 0;
}
To read the text containing blank space, cin.get function can be used. This
function takes two arguments.
First argument is the name of the string (address of first element of string)
and second argument is the maximum size of the array.
In the above program, str is the name of the string and 100 is the maximum
size of the array. 10/5/2023 99
Strings that are objects of string class (string Object)
In C++, programmer can also create a string object for holding strings.
Unlike using char arrays, string objects has no fixed length, and can be
extended as per the requirement.
//Example: C++ string using string data type
#include <iostream>
using namespace std; Output
int main()
{ Enter a string: Programming is fun.
// Declaring a string object You entered: Programming is fun.
string str;
cout << "Enter a string: ";
getline(cin, str);
cout << "You entered: " << str << endl;
return 0;
}
In this program, a string str is declared. Then the string is asked from the user.
Instead of using cin>> or cin.get() function, programmer can get the entered line of
text using getline().
getline() function takes the input stream as the first parameter which is cin and str as
the location of the line to be stored. 10/5/2023 100
C++ supports a wide range of functions that manipulate
null-terminated strings.
S.
Function Purpose
No.
1 strcpy(s1, s2); Copies string s2 into string s1.

2 strcat(s1, s2); Concatenates string s2 onto the end of string s1.

3 strlen(s1); Returns the length of string s1.


Returns 0 if s1 and s2 are the same; less than 0 if s1<s2;
4 strcmp(s1, s2);
greater than 0 if s1>s2.
Returns a pointer to the first occurrence of character ch in
5 strchr(s1, ch);
string s1.
Returns a pointer to the first occurrence of string s2 in
6 strstr(s1, s2);
string s1.

10/5/2023 101
Following example makes use of few of the system-defined functions. When
this code is compiled and executed, it produces result such as:
#include <iostream>
#include <cstring> // concatenates str1 and str2
using namespace std; strcat( str1, str2);
cout << "strcat( str1, str2): " << str1 << endl;
int main ()
{ // total length of str1 after concatenation
char str1[10] = "Hello"; len = strlen(str1);
char str2[10] = "World"; cout << "strlen(str1) : " << len << endl;
char str3[10];
int len ; return 0;
}
// copy str1 into str3
strcpy( str3, str1);
cout << "strcpy( str3, str1) : " << str3 << endl;

Output

strcpy( str3, str1) : Hello


strcat( str1, str2): HelloWorld
strlen(str1) : 10 10/5/2023 102
The String Class in C++
The standard C++ library provides a string class type that supports all the
operations mentioned above, additionally much more functionality. See the
following example:
#include <iostream>
#include <string> // concatenates str1 and str2
using namespace std; str3 = str1 + str2;
cout << "str1 + str2 : " << str3 << endl;
int main ()
{ // total length of str3 after concatenation
string str1 = "Hello"; len = str3.size();
string str2 = "World"; cout << "str3.size() : " << len << endl;
string str3;
int len ; return 0;
}
// copy str1 into str3
Output
str3 = str1;
str3 : Hello
cout << "str3 : " << str3 << endl; str1 + str2 : HelloWorld
str3.size() : 10 10/5/2023 103
Thanks
Any Question
?
Advance Programming Language (C++) | Department of IT | Stage-2 Sem-1 10/5/2023 104
Lebanese French University

College of Engineering and Computer Science


Department of Information technology
First Semester
2023 - 2024

Asst. Prof. Ashish Sharma


[email protected]

ADVANCE PROGRAMMING LANGUAGE (C++)


Lecture 14
Outlines
• Namespaces in C++

Advance Programming Language (C++) | Department of IT | Stage-2 Sem-1 10/5/2023 106


Namespaces
Namespaces are used to organize too many classes, so that it can be easy
to handle the application.

In simple words, namespace is a collection of namespaces and classes in


an application.

A namespace is designed to overcome this difficulty and is used as


additional information to differentiate similar functions, classes, variables
etc. with the same name available in different libraries.

Using namespace, programmer can define the context in which names are
defined. In essence, a namespace defines a scope.

In C++, a namespace definition begins with the keyword namespace


followed by the namespace name.

10/5/2023 107
For accessing the class of a namespace, programmer needs to use
namespace_name : : class_name
Programmer can use using keyword before class to declare a namespace, so
that programmer does not need to use complete name all the time.
In C++, global namespace is the root namespace. The global::std will
always refer to the namespace "std" of C++ Framework.

The general Syntax for defining a namespace, such as:


namespace namespace_name
{
// code declarations
}

To call the namespace-enabled version of either function or variable,


prepend (::) the namespace name as follows −
name : : code; // code could be variable or function.

10/5/2023 108
To write a small C++ program
Output with cout

cout << “Every age has a language of its own\n”;

The identifier cout (pronounced “C-out”) is actually an object. It is


predefined in C++ to correspond to the standard output stream.
The operator << is called the insertion or put to operator.
It directs the contents of the variable on its right to the object on its left.
In FIRST it directs the string constant “Every age has a language of its
own\n” to cout, which sends it to the display.

Output with
cout

10/5/2023 109
Input with cin
cin >> ftemp;
The statement causes the program to wait for the user to type in a number.
The resulting number is placed in the variable ftemp.
The identifier cin (pronounced “C-in”) is an object, predefined in C++ to
correspond to the standard input stream.

Input stream represents data coming from the keyboard.

The >> is the extraction or get from operator. It takes the value from the
stream object on its left and places it in the variable on its right.

Input with
cin

10/5/2023 110
//Basic Program to print Hello, LFU..!!!

#include <iostream> #include <iostream>


using namespace std;
//Program execution begins from main()
//Program execution begins from main() int main()
int main()
{
OR {
std::cout << "Hello, LFU..!!!";
cout << "Hello, LFU..!!!"; return 0;
return 0; }
}

OUTPUT

Hello, LFU..!!!
10/5/2023 111
Explanation about the various parts of the above program, such as:
• The C++ language defines several headers, which contain information
that is either necessary or useful to the program. For this program, the
header <iostream> is needed.

• The line using namespace std; tells the compiler to use the Standard
(std) namespace.

• The next line '// Program execution begins from main()' is a single-line
comment available in C++. Single-line comments begin with // and stop
at the end of the line.

• The line int main() is the main function where program execution
begins.

• The next line cout << "Hello, LFU..!!!"; causes the message "Hello,
LFU..!!!" to be displayed on the screen.

• The next line return 0; terminates main( ) function and causes it to


return the value 0 (Zero) to the calling process. 10/5/2023 112
//Simple example of namespace which include variable and functions.
#include <iostream>
using namespace std;

namespace First {
void sayHello() {
cout<<"Hello First Namespace"<<endl;
}
}

namespace Second {
void sayHello() {
cout<<"Hello Second Namespace"<<endl;
}
}
Output
int main()
Hello First Namespace
{
Hello Second Namespace
First :: sayHello();
Second :: sayHello();
return 0;
10/5/2023 113
}
//Namespace example: by using namespace keywords
#include <iostream>
using namespace std;

namespace First{
void sayHello(){
cout << "Hello First Namespace" << endl;
}
}
namespace Second{
void sayHello(){
cout << "Hello Second Namespace" << endl;
}
}

using namespace First; Output


int main ()
Hello First Namespace
{
sayHello();
return 0;
} 10/5/2023 114
Thanks
Any Question
?
Advance Programming Language (C++) | Department of IT | Stage-2 Sem-1 10/5/2023 115

You might also like