0% found this document useful (0 votes)
17 views35 pages

OOPs Notes Unit-2

Uploaded by

tyagiprashant268
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)
17 views35 pages

OOPs Notes Unit-2

Uploaded by

tyagiprashant268
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/ 35

INDERPRASTHA ENGINEERING COLLEGE, GHAZIABAD

APPROVED BY AICTE & AFFILIATED TO CHAUDHARY CHARAN SINGH UNIVERSITY,


MEERUT (COLLEGE CODE-1249)
63 SITE-IV, SAHIBABAD INDUSTRIAL AREA,
SURYA NAGAR FLYOVER ROAD SAHIBABAD, GHAZIABAD – UP

SUBJECT NAME: Object Oriented Programming using C++​ SUBJECT CODE: BCA-301

FACULTY NAME: RENU KALA

NOTES
Unit -2

Classes and Objects


Define class and an object in C++ with example in details?
Solution: Since C++ is the inception programming language for the oops(object oriented
programming structure) concept to implement. So we need to have the introduction of the
class oops concept.
1)​ class
The class is a way to create an object in the main () or anywhere. The class is the blueprint or
the prototype for an object.
Whatever process need to implements or execute on an objects has to be define in the class
body in the form of the member function or methods.
The various characteristics of the class is as follows
1)​ Class is the main source to create a user define data type of the class type.
2)​ Using class an object declares .And since the class creates by the user then the class is
better known as user define data type.
3)​ The class have basically 2 parts
a.​ In the first parts the private data members declares.it is also called as instance
variable, an attributes of the class
b.​ In the second part the public member function can be define.
4)​ By default all the members of the class is private .we can explicitly define the member
function as public
5)​ The Data member of the class declares as private implementing the concept of
data hiding.
6)​ In the class body the private data member can be use or access by public
member function implementing oops concept encapsulation.
a.​ All the member function(methods) of the class defines as public hence it can
be access by an object outside the class body i.e. in the main()
7)​ The class body enclosed between { and } and class body always terminates by semi
colon(;)
class <class_name>
{
};
8)​ By default the member function define inside the class body are inline member
function
Example
Class A
{
public:
void display()
{
Cout<<”\n\tThis is an example of class”
}
}; // end of the class
9)​ If the public member function only declares inside the class body but define outside
the class body using scope resolution operator (::) then it is called non-inline member
function.

class A
{
public:
void dis();

}; // end of the class

Definition of the non-inline function


void A::dis()
{
cout<<”\n\t This is an example of the class
}

An example of the c++ class using inline function


/*
An example of the class using inline function
*/
#include
<iostream.h>
#include <conio.h>
class student
{

// private data member


int rollno;
char name[20];
public:
// public member function
void getstud()
{

cout<<"\n\t Enter Rollno:";


cin>>rollno;
cin.get();

cout<<"\n\t Enter the name:";


cin.getline(name,20);
}

void putstud()
{
cout<<"\n\t The student :"<<name<<" has Rollno "<<rollno ;
}
};
void main()
{
student x,y ; // 2 object of the student type(class)
clrscr();
cout<<"\n\t input for X ";
x.getstud();
cout<<"\n\t Input for Y";
y.getstud();
cout<<"\n\t\t To Display for X";
x.putstud();
cout<<"\n\t\t To Display for Y";
y.putstud();
getche();

}
2)​ Object
An object always represent an entity for the class. So we can declare an object using
the class type i.e. an user define data type
There are various characteristics of an object are as follows
a)​ An object is always declares of type class which is a user define type hence an object
declares using class type.
class A
{
};
void main()
{
A *p = new A() ; // p is an instance of class Type A

}
b)​ An object always invoke or calls the public member function (public members not the
private members) outside the class body mainly in the main().
c)​ To call or invoke the public member (public member function) the dot operator (.) use
and it is call or invoke by the pointer object then it may be call using arrow
operator( ) operator.
Example
Class A
{
Public:
void disA()
{

}
};
Main()
{
A x ; // simple object
A *p; // pointer object
x.disA(); // use dot opr
p disA(); // use arrow opr
}
d)​ An object when declares using “new” keyword then an object is called an “instance”.
e)​ We can also declare an array of object using class type in the same way declaring
primitive type array
Class A
{
}; // end of the class
Void main()
{
A x[10] ; // an array of an object
}
f)​ Where there is no explicit constructor defines by the user then object declaration calls
an implicit default constructor.
g)​ There can be multiple object defines of the single class and each object has its own
data member value which need to be initialise.
Example
#include
<iostream.h>
#include <conio.h>

class student
{
int roll;
char name[20];
public:
//default constructor
student()
{
roll=11101;
strcpy(name,"Raman kumar");
}
//parameterized constructor
student(int r, char *n)
{
this->roll=r ; //roll=r ;
strcpy(name,n);
}
void display()
{
cout<<"\n\t The "<<name<<" has rollno:"<<roll;
}
};
void main()
{
student x ; // calls default
student y(3124,"Gagan sharma");
clrscr();
x.display(); // print x data member
values y.display(); // print y data member
values getche();
}
Define an attributes in c++ class
In C++ , class has 2 parts or section. In the first section the private data member or an
instance variable declares in the form of an attributes or fields and in the second section the
public member function or the methods defines.
In C++ class the declares attribute plays very important part since an attributes declares in the
form data members or an instance variable
1)​ An attribute (data member) can be declares of any C/C++ Data types. It can be either
any primitive type(int,float,char,double) or user define type(struct,union,class)
2)​ An attribute can be declares in the form of an array also of any type.
3)​ By default all these attribute or data member can be declares as private, So they can’t
be access outside the class body or in the main() using the class object or an instance
implementing the oops concept data hiding or information hiding
4)​ Since these private data members(an attributes) can’t be access outside the class body
via an object of the class type then all attributes can only be use or access inside the
class body via public member function implementing an oops concept known as
encapsulation
class student
{
// private data members(attributes)
int rollno;
char name[20];
public:
student(int r, char *n)
{
rollno=r;
strcpy(name,n);
}
}; // end of the class
In this example 2 attributes declares of primitive type which is private so can’t
be visible outside the class body. Then it can only be used by the public member
function i.e. used inside define constructor implementing the oops concept
encapsulation.

5)​ By default all the declare attribute/data members are non static hence the value
of different objects are different since all the non-static attributes are declares for
an object.
#include <iostream.h>
#include <conio.h>
class A
{
int a,b,s ;

public:
A()
{
a=55;
b=33;
}
A(int a,int b)
{
this->a=a;
this->b=b;
}
void disp()
{
cout<<"\n\tA is:"<<a;
cout<<"\n\tB:"<<b;
}
};
void main()
{
A x ; // calls default constructor
A y(76,45);
clrscr();
cout<<"\n\tX is :";
x.disp();
cout<<"\n\tY is :";
y.disp();
getche();
}
In this example the values of attribues a and b for object X is 55 and 33 and for object
Y are 76 and 45
6)​ An attribute are also called data member when simple object declares but when
object declares using “new” keyword then it an object is called an instance and an
attributes becomes an instance variable.
7)​ The value of an attributes can also be initialise using constructor. (see an example of
point 5 where default and parameterized constructor use)
8)​ We have static data member (attribute) also which only declare for the class only not
for an object. It can be declare inside the class body but can be initialise outside the
class body using scope resolution operator (::). The value of these static attribute can
be share by every object of the class.
/*
An example of the static data member
*/
#include
<iostream.h>
#include <conio.h>
class A
{
static int count; // declaring static data member
public:
A() // default constructor
{
count++;
cout<<"\n\t"<<count<<" object creates ";
}
A(char *n) // parameterised constructor
{
count++;
cout<<"\n\t"<<count<<" object creates ";
}
~A() // destructor
{
count--;
cout<<"\n\t"<<count<<" object left ";
}
}; //end of the class
int A::count=0; // static data member initialise to 0
void main()
{
clrscr();
A x ; // calls default
A y("Raj");
//destructor calls here
}

Define methods in c++?


Solution: In c++ the function can be define in the class or without class in the simple c++
program like C.
So when we define the function without class then it is called methods but when any function
define inside the class then it is called member function.
So in c++ the methods can also be called the member function when it is defining inside the
class body.
There are several characteristics of the member function such as
1)​ Same as any function the member function can also return value of any
type. Class A
{
int sum(int m,int n)
{
int s ;
s=m+n;
return s;
};
} // end of the clas
void main()
{
A x ; // an object of the class A
int k;
k=x.sum(); // k stores the return value
}
2)​ Same as any normal function the parameter can also be pass of any type in any
number in the member function define in the class. An argument can be pass usually
in 3 types
a)​ Parameter pass by value
b)​ Parameter pass by reference
c)​ Parameter pass by reference
3)​ In c++ class the member function can be define as a public so they can be invoke
or access by an object or by an instance of the same class outside the class body.
4)​ In class, the private data member or an instance variable can only be access by the
public member function leading to oops encapsulation concept.
5)​ In c++ class , the member function can be define in 2 ways
a)​ Inline member function : are those which defines inside the class body.
b)​ Non inline member function: are those which defines outside the class
body using scope resolution operator(::).
6)​ There are some special member function define inside the class body known as
a)​ Constructor: create memory for an object and also initialise data
member value
b)​ Destructor: Delete memory which already created by constructor.

Example
class emp
{
char ename[20];
public:
emp(int r, char *n) // constructor
{
}
~emp() // destructor
{
}
}; // end of the class
7)​ The define member function in the class body can be either
a)​ Non static: The non-static member function can be define only for an
object. Means the same non-static member function can be call multiple
times by different object having different this value.
b)​ Static member function: The static member function can be define for the
class only. Hence it can also be call via class_name
/*
An example of the static and non-static
membver function
*/

#include <iostream.h>
#include<conio.h>

class A
{
public:
//defining static method
static void staticmth()
{

cout<<"\n\tThis is static method ";


}
// defining non static method
void nonstat()
{

cout<<"\n\t This is non static method";


}
};
void main()
{
A x,y ; // 2 object of the class A
clrscr();
x.nonstat();

y.nonstat();
A::nonstat(); // error cant call non static method by class
A::staticmth();
getche();

}
Define C++ class Declaration with example
To implements various oops concept we have to define the class because all oops concept
implements by using an object or by an instance. And since object declares by class type then
to declare an object we have to first define the class.
State identity and behaviour of an object
An object is the main concept of the oops.it is declare using the class type means an object
always declare using class type.
1)​ An object represent in the form an entity.
2)​ An object is the main oops concept in c++ and an object always represent the class
3)​ All the public define member function of the class can be call or invoke via an object
in the main() or anywhere outside the class.
4)​ An object declares using the class type i.e. the user define type.
5)​ Inside the member function “this” pointer always stores an address of an
invoking object
6)​ We can declares as many object of the same class type in the main()
class A
{
}
void main()
{
A x,y,z; // declares 3 object
}

7)​ We can also declare an array of an object of the class


type class A
{
}
void main()
{
A x[10]; // declares an array of an object
}
8)​ When declaring an object using the “new” keyword then it is called an instance and
the process is called an instantiation, then all the private data members then called
instance variable.
9)​ In the class the non-static data member and the non-static member function declares
and define for an object. We do have different copies of data member for different
object and the single non static member function calls multiple times from different
objects.
Example
Many example above just check it out

Explain the default parameter in c++ member function or in method?

Solution
In C and C++, we can pass an argument in user define function. An actual
argument can be pass in function call or when any member function call using an
object and formal parameter can be pass when function define. The data type of
both parameter and argument must be same because the value of actual argument
stores in formal parameter.
But default value can also be pass in the formal parameter which can only be use
then, when no value from actual argument pass to formal parameter.
So when the formal parameter initialises with some value then it is called the default
parameter value.
And this default parameter value can only be used in function definition when no
value pass from function call in the form of an actual argument.
An example of the default parameter

In this example formal parameter m and n initialises with 14 and 10 respectively


In this example in function sum() both default value of the formal parameter comes in
use because there is actual argument value pass from function call.
And in the same way in sum(a) only n default value use and “m” value will be 65
since its value has come from function call
And in sum(a,b) No default values use

Define an instantiation of an objects in c++?

Solution: Usually in c++ an object declares using class user define type. So for that
we have the class first and then declares an object.
Normally when a simple variable declares using the class type then it is called an
object declaration.

But when any object of the class type declares using “new” keyword then it is called
an instance declaration and the process is called an instantiation
In, this memory is allocated for that object and the class constructor run.
When we declare the simple object of the class type then it is created on the stack
But when an instance create then its memory creates at heap. The memory creates
using constructor for an object. When an instance calls then constructor calls.
In the instantiation process, all the data member are called an instance variable

According to constructor type an instance can be declare using 3 ways

1)​ Using default constructor: when no argument pass


2)​ Using parameterised constructor: when an argument pass of same type as data
member
3)​ Using copy constructor: when an object pass in instance declaration

An example
/*
An example of an instantiation in oops
*/
#include<iostream.h>
#include<conio.h>
#include <string.h>

class student
{
int roll;
char name[20];
public:
student() // default constructor
{
roll=2134;
strcpy(name,"gagan singh");
}
student(int r, char *n) // parameterized constructor
{
roll=r;
strcpy(name,n);
}
student(student &s)//copy constructor
{
roll=s.roll;
strcpy(name,s.name);
}
void display()
{
cout<<"\n\t The name "<<name<<" has "<<roll;
}
~student() // destructor
{
cout<<"\n\tBye "<<roll;
}
}; //end of the class
void main()
{
student *p= new student() ; // usinjg default constructor
student *q= new student(6754,"Ramesh Verma"); //using the parameterised
constructor
student *r= new student(*q) ; //using the copy constructor
clrscr();
p-​>display();
q-​>display();
r-​>display();
delete p; // calls destructor for p
delete q; //​ q
delete r; //​ r
getche();

----------------------------------------------------------------------------------------------

Explain constructor and destructor in c++?


Solution: Constructor and destructor are the special member function which is use to
allocate and destroy the memory for any given object.
Constructor:
1)​ Constructor are the special member function which is use to allocate the memory for
any given object
2)​ Also using constructor the data member (instance variable) value can be initialises.
3)​ The constructor member function does not have the return type since constructor can’t
return any value.
4)​ Constructor calls automatically when it reads an object/instance declaration. No need
to call it explicitly as it happens with the other member function.
5)​ Constructor name is same as the class name .So the name of the constructor is
based on the class name
class account
{
int acct_no;
char act_type[20];
public:
account() // default
{
}
account(int ano, char *act) //parameterized
{

}
};//class end
6)​ We can have multiple constructor in the same or in single class of the same name
since constructor name is same class name.
7)​ When defining multiple constructor which having the same name but having different
number of argument and their type then this is called constructor overloading
8)​ Constructor neither be define as virtual nor it defines as a friend function
9)​ Constructor can’t be static since rather they defines non-static since they always
defines for an object not for the class
10)​Types of constructor
There are basically 3 types of constructor in c++ oops
(i)​ Default constructor: when no parameter pass in the constructor then it is
called the default constructor. Hence no value is passed in the form of actual
argument when declaring an object. So the data members initialises from
default values for any given object.

Example
class student
{
int roll;
char name[20];
public:
student() // default constructor
{
roll=3213;
strcpy(name,”Ram Sharma”);
}
} ; //end of clas
main()
{
student x; // calls default
student *p= new student(); // also call default constructor
}
(ii)​ Parameterised constructor: when in constructor the parameter pass in same
number and of same type as declares data member of the class then the define
constructor is called parameterised constructor. Then we have to pass the
value when declaring an object /instance for the data member.
Means data member value initialises from the pass value in the parameterised
constructor
Example
class student
{
int roll;
char name[20];
public:
student(int r, char *n) // paramaterised constructor
{
roll=r;
strcpy(name,n);
}
} ; //end of clas
main()
{
student x(5467,”sanjay sharma”); // calls parameterised
student *p= new student(6743,”pankaj”); // also call parameterised
constructor
}
(iii)​ Copy constructor: when object declares and pass another already
declares object in the form of an actual argument then this object
declaration automatically invoke copy constructor if define in the class
body by the user.
So the copy constructor take the reference of the class type object in the form
of the parameter.
The copy constructor does member by member copy of pass argument
reference object to this(invoking) object data member value

Example
class student
{
int roll;
char name[20];
public:
student(int r, char *n) // paramaterised constructor
{
roll=r;
strcpy(name,n);
}
student(student &s) // copy constructor
{
roll=s.roll;
strcpy(name,s.name);
}
} ; //end of clas
main()
{
student x(5467,”sanjay sharma”); // calls parameterised
student y(x) // calls copy constructor copies x data member to y data member
}

Full example of constructor


/*
An example of an instantiation in oops
*/
#include<iostream.h>
#include<conio.h>
#include <string.h>

class student
{
int roll;
char name[20];
public:
student() // default constructor
{
roll=2134;
strcpy(name,"gagan singh");
cout<<"\n\t This is default constructor";
}
student(int r, char *n) // parameterized constructor
{
roll=r;
strcpy(name,n);
cout<<"\n\t This is parameterised constructor";
}
student(student &s)//copy constructor
{
roll=s.roll;
strcpy(name,s.name);
cout<<"\n\t This is copy constructor";
}
void display()
{
cout<<"\n\t The name "<<name<<" has "<<roll;
}
~student() // destructor
{
cout<<"\n\tThis is destructor";
cout<<"\n\tBye "<<roll;
}
}; //end of the class

void main()
{
clrscr();
student x ; // using default constructor
student y(6754,"Ramesh Verma"); //using the parameterised constructor
student z(y); //using the copy constructor

x.display();
y.display();
z.display();
//At this point the destructor calls for x ,y ,and z object
getche();

}
Define Destructor with example
The destructor is also the special member function like the constructor but its execution is
different from the constructor. Constructor creates but destructor destroy.
Destructor is the special member function which frees or destroys the allocated memory.
1)​ To define the destructor same as constructor we use the “class name”. So like
constructor the name of the destructor is also same class name.
2)​ There can be only one destructor define in the single class for all the objects. So we
don’t have any destructor overloading concept.
3)​ Constructor calls when object declares but destructor automatically calls or invoke
at the end of the program or the main(). it doesn’t require any explicit invocation.
4)​ The destructor calling sequence is just opposite to constructor calling. Means the
destructor of the last object declaration calls first and first object declaration
destructor calls first.
5)​ To define the destructor member function there is a use tilde(~) sign put before the
destruction name.
Example
class A
{
public:
~A() // define the destructor
{

}
};
6)​ Like constructor, destructor also can’t return any value so there is not any return type
in destructor also.
7)​ No parameter can be pass in destructor unlike constructor.

Example of the destructor

Please go through the full example of constructor

Difference between constructor and destructor


Constructor Destructor
Creates memory for an object Destroy memory for an object
Initialise instance variable/data member Doesn’t initialise data member value
value for an object
Can have multiple constructor in the Have only single destructor for all
single class objects in the class
Can pass the parameter in the No parameter pass in the destructor
constructor
No special char use to define the Special char tilde(~) use to define the
constructor destructor

Calls at the time of object declaration It calls at the end of the main()
automatically. No need for an object
declaration
First object declaration constructor calls Last object declaration destructor calls
first and then so on first and so on
Can have different types of constructor No types
such as default, parameterised, copy

----------------------------------------------------------------------------------------------------------------
Explain an abstract class/Meta class in c++
Or
Explain pure virtual function in c++
Solution
Usually if the class defines by the user then its object creates but abstract class are those
class whose object/instance can’t be created. So an abstract class are those class which can’t
be instantiated.
And in c++ to create an abstract class we need to use the concept of pure virtual function
(abstract member function).
And an abstract class can always be the base class only since this concept always be
implement using inheritance oops concept.
(a)​ The pure virtual function only declares in the base class it can be define or over ride
in its derived class.
(b)​The class where the pure virtual function only declares by default or automatically
becomes an abstract class which must also be the base class and then this abstract
class object or an instance cannot be created or declare in the main()
(c)​ To declare the pure virtual function there is the use of keyword “virtual” before
return type and also use “=0;” at the end of the declaration.
(d)​Syntax
virtual <return_type> <function_name>(parameter)=0;
example
void sum(int,int)=0;
(e)​ In the abstract class we can also define the concrete method
(f)​ If no instance declare of the abstract class then its concrete member function can
now be invoke or call using its derived class object.
(g)​We can override the pure virtual function in as many as classes depending of the
type inheritance using.
(h)​ ​
Full example after commenting the above error code
/*
An example of the pure virtual function or an abstract class
*/
#include
<iostream.h>
#include <conio.h>

class abs
{
protected:
int a,b,s ;
public:
abs(int m, int n)
{
a=m ;
b=n;
}
void display() // defining the concrete method
{
cout<<"\n\t A:"<<a;
cout<<"\n\t B:"<<b;
}
//declaring the pure virtual fnc
virtual int sum()=0;
virtual int minus()=0;
}; // end of the abstract class
class inh:public abs
{
public:
inh(int a,int b):abs(a,b) // calls base class constructor
{

}
int sum()
{
s=a+b ;
return s ;
}
int minus()
{
s=a-b ;
return s;
}

}; //end of the derived class


void main()
{
//abs x(54,32); //error
inh y(54,32); //ok
/*
abs *x = new abs(54,31);
//error inh *y = new inh(54,31);
​ //ok
*/
y.display();
int k ;
k=y.sum();
cout<<"\n\tA+B:"<<k
; k=y.minus();
cout<<"\n\tA-B:"<<k;
getche();
}

Define an object type in c++

Solution: In C++ , object can be declare using the class type , means we have to create
the class first and then of that class type (user define data type) an object declares. So
the main concept is that an object type is the class type.
An object type also can be define in term of encapsulating the private data member
through member function.
Since the data member declares using as private and these private data member
(attributes) can be access by public member function these concept is called oops
concept encapsulation.
So an object type is a user define composite data type that encapsulate the data
member with the function which manipulates the value of the data member for any
object or an instances.
#include
<iostream.h>
#include <conio.h>
#include <string.h>
class emp
{
int ecode;
char name[20];
float sal;
public:
emp() // default constructor
{
ecode=2141;
strcpy(name,"Ram Sharma");
sal=67000;
}
emp(int e, char *n, float s) //parameterised constructor
{
ecode=e ;
strcpy(name,n);
sal=s ;
}
void displa()
{
cout<<"\n\tThe employee:"<<name<<" having code:"<<ecode<<" draws:"<<sal<<"
salary";
}
};//end of the class

void main()
{
emp x ; // calls default constructor
emp y(5678,"Jai Veeru", 61000);// calls parameterized constructor
clrscr();
proc
y.displa();
getche();
}

In this example the private data member encapsulates by member function constructor
and displa() for the given object x and y of class employee. This process is called an
object type.

Difference between procedural oriented and object oriented (Year-2022)


Procedure oriented Object oriented
Use in C and also in C++ both Can use in C++ but not in C
It is also called modular or structural It is only called object oriented
programming
It is based on the function It is based on the class and then on
object
When a single program divides in when first the class define with the
multiple function then it is called encapsulation of private data members
procedural oriented or modular and then public member function and
programming or structure programming then declaring an object of the class type
language. then it is called an object oriented
It follows top-down approach It follows bottom up approach
We can’t use protected, private and There is a protected, private and public
public visibility mode visibility mode use in oops
There is no data hiding concept in PO There is a concept of data hiding in oops
Which enables the data declares in the
class hide from outside the class.
No inheritance, polymorphism, We have the concept of inheritance,
encapsulation ,etc concept use in PO polymorphism, encapsulation ,etc in
oops

There is no generic programming in PO We have the generic programming in


oops in the form of template

Q find out an area of rectangle, triangle and circle using function overloading?
Solution: (year 2022)
/* To find out an area of circle , rectangle and triangle using fucntion
overloading
*/

#include <iostream.h>
#include <conio.h>

int area(int,int);
float area(float);
float area(float,float);

void main()
{
int l,b,rectar;
float r,circlear;
float bs,hg,triar;
clrscr();
l=20;
b=14;
rectar=area(l,b);

cout<<"\n\t An area of the rectangle is:"<<rectar;


r=2.2;
circlear=area(r);

cout<<"\n\t An area of the circle :"<<circlear;


bs=5.5;
hg=6.3;
triar=area(bs,hg);
cout<<"\n\t An area of the triangle:"<<triar;
getche();
}

int area(int l,int b)


{
int ar ;
ar=l*b;
return ar;
}

float area(float r)
{
float ar ;
const float pi=3.14;
ar=pi*r*r;
return ar;

}
float area(float b,float h)
{
float ar ;
ar=(b*h)/2;
return ar;
}

output
/*
Write the C++ program to print the folloing series
0+1+2+3+4+5+6+7+8+9+…..+N (year-2022)
*/

You might also like