Download as pdf or txt
Download as pdf or txt
You are on page 1of 103

18CS202J

Object Oriented Design and


Programming

Unit - 1
Comparison between procedural and object oriented
programming

Procedural Programming Object Oriented Programming


It deals with algorithms It deals with data
Programs are divided into functions Programs are divided into objects
Most of the functions share global data to Local declaration is possible
all the functions
Top down approach Bottom up approach
Doesn’t support exception handling Supports exception handling
Middle level language High level language
Data is not secured Data is hidden
OOPS features
1. Classes
• A class provides a template or a blueprint that describes the
structure and behavior of a set of similar objects.

• Once we have definition for a class, a specific instance of the


class can be easily created.

• Class is a collection of objects of similar type.

• Eg: fruit mango


Class Student
{
Private:
int rno;
char name[20]; Attributes/Data Members

float marks;
Public:
get_details();
Operations/ Member function
show_details();
};
2. Objects

• Objects are the basic run time


entities in object oriented system.

• Object take up space in the


memory and have an associated
address like a record in pascal or a
structure in C.

• When a program is executed the


objects interact by sending
messages to one another.
3. Data Encapsulation

•The wrapping up of data and functions into a single unit is known as encapsulation.

•The data is not accessible to the outside world and only those functions which are
Wrapped in the class can access it.

•The insulation of the data from direct access by the program is called data hiding or
Information hiding.

4. Data Abstraction

•Abstraction refers to the act of representing essential features without including the
background details and explanations.
5. Inheritance

The inheritance is the process by which objects of one class


acquire the properties of objects of another class.

Base Class/ Parent/


Automobile Super class

Two Wheeler Three Wheeler Four Wheeler

Derived class/
Child/ Sub class
Scooter Motor Bike Auto Rickshaw Car Bus
Types of Inheritance

• Single level
• Multi level
• Multiple
• Hierarchical
• Hybrid
6. Polymorphism
• Ability to take more than one form.
• It includes
Function Overloading
Operator Overloading
7. Function Overloading
• Function Overloading refers to use of same function
name for different purposes. These functions differ from
each other by no. and types of arguments.

Draw()

Draw() Draw() Draw()


8. Operator Overloading

• Operator Overloading is a mechanism of redefining the


meaning of C++ operators.
• For example: +, - ,++, -- ,* etc.
9. Method and Message Passing

• A method is a function associated with a class.


• It defines the operations that the object can execute when it
receives a message.
• Objects communicate with one another by sending and
receiving information.
• Every object of the class has its own set of values.
10. Containership

• The ability of a class to contain objects of one or more classes


as member data.
• Eg: class 1 can have an object of class 2 as its data member.
• Containership is also called composition (has-a relationship).
• Class one is composed of class two.

Inheritance

composition
11. Genericity
• To reduce code duplication and generate short simpler code
c++ supports the use of generic codes (or templates) to define
the same code for multiple data types.

• This means that a generic function can be invoked with


arguments of any compatible type.

Templates are of two types


• Function Template
• Class Template
Reusability & Delegation
• Developing codes that can be reused in same program or in
different programs.

• Reusability can be attained through inheritance, containership,


polymorphism and genericity.

• Delegation provides the maximum flexibility to generate


reusable codes.

• The property of delegation emphasizes on the ideology that a


complex object is made of several simpler objects.

• Delegate exhibits has-a relationship (Containership or


Composition).
Advantages of OOPs

• Data Security.
• Reusability of existing code.
• Creating new data types.
• Abstraction.
• Less development time.
• Reduce Complexity.
• Better Productivity.
STRUCTURE OF C++ PROGRAM
Header files

input data output data

Keyboard executing Screen


program

• C++ treats input and output as a stream of characters.


• stream : sequence of characters (printable or nonprintable)
• The functions to allow standard I/O are in iostream header
file or iostream.h.
• Thus, we start every program with #include <iostream.h>
Insertion operator (<<)

• Variable cout is predefined to denote an output stream that


goes to the standard output device (display screen).

• The insertion operator << called “put to” takes 2 operands.

• The left operand is a stream expression, such as cout. The


right operand is an expression of simple type or a string
constant.
Extraction operator (>>)

• Variable cin is predefined to denote an input stream from


the standard input device (the keyboard)

• The extraction operator >> called “get from” takes 2


operands. The left operand is a stream expression, such as
cin--the right operand is a variable of simple type.

• Operator >> attempts to extract the next item from the


input stream and store its value in the right operand
variable
Syntax for output statements

SYNTAX
cout << Expression << Expression . . . ;

cout statements can be linked together using << operator.


These examples yield the same output:

cout << “The answer is “ ;


cout << 3 * 4 ;

cout << “The answer is “ << 3 * 4 ;


Output: The answer is 12
Output statements

• String constants (in double quotes) are to be printed as is,


without the quotes.

cout<<“Enter the number of candy bars ”;


OUTPUT: Enter the number of candy bars
“Enter the number of candy bars ” is called a prompt.

• All user inputs must be preceded by a prompt to tell the user


what is expected.

• You must insert spaces inside the quotes if you want them in
the output.

• Do not put a string in quotes on multiple lines.


Syntax for input statements

SYNTAX
cin >> Variable >> Variable . . . ;

cin statements can be linked together using >> operator.


These examples yield the same output:

cin >> x;
cin >> y;

cin >> x >> y;


User inputs: 3 4
Assigns x = 3 and y = 4
C++ Data Types

simple structured

integral enum floating array struct union class

char short int long bool

address
float double long double

pointer reference
C++ Primitive Data Types

Primitive types

integral floating

char short int long bool float double long double

unsigned
What is a Variable?

• A variable is a memory address where


data can be stored and changed.

• Declaring a variable means specifying


both its name and its data type.
Variable Declaration

• All variables must declared before use.


– At the top of the program
– Just before use.
• Commas are used to separate identifiers of
the same type.
int count, age;

• Variables can be initialized to a starting


value when they are declared
int count = 0;
int age, count = 0;
What Does a
Variable Declaration Do?

• A declaration tells the compiler to allocate


enough memory to hold a value of this
data type, and to associate the identifier
with the location.
• int ageOfDog;
• char middleInitial; 
• float taxRate;
Constants
• Syntax: const type identifier = value;
• Ex: const double TAX_RATE = 0.08;
• Convention: use upper case for constant
ID.
C++ Constants are also like normal variables. But, only difference
is, their values can not be modified by the program once they are
defined.
Constants refer to fixed values. They are also called as literals
Constants may be belonging to any of the data type.
Syntax:

const data_type variable_name;


Example
Const float TAX =0.08;

Types of C constant:
Numeric Constant
Integer constants ex. 10 20 -30
Real or Floating point constants ex 10.34 -90.30 0.6e4
Character Constant
Character constants ex. ‘3’ ‘a’
String constants ex.”Chennai” “preethi”
Type Conversions
• Concept of converting the value of one type into
another type.
• Two types of conversion
– Implicit Conversion
• Conversion done automatically
• Loss of data will be there, no control in our side.
• Smaller type converted into wider type eg: int to float.
– Explicit Conversion
• We have control of converting it from one type to another.
• We can prevent loss of data.
int main()
{
int a;
double b=12.5;
a=b; Implicit Type Conversion
cout<<a;
a=int (b);
Explicit Type Conversion
cout<<a;
}
Explicit type conversion
int main()
{ Output
a=25
int a = 25; b=35.87
Converts int to float = 25.00
float b = 35.87; Converts float to int = 35

cout<<“a=“<<a;
cout<<“b=“<<b;
cout<<“ converts int to float”<<float(a);
cout<<“converts float to int”<<int(b);
return 0;
}
Pointers
• A pointer is a variable whose value is the address of
another variable.
• type *var-name;
• int *ip; // pointer to an integer
• double *dp; // pointer to a double
• float *fp; // pointer to a float
• char *ch // pointer to character
(a) We define a pointer variable.
(b) Assign the address of a variable to a pointer.
(c) Finally access the value at the address available in the
pointer variable.
• Write a program to swap two numbers without
using third variable.
Classes
Access specifier
• Access modifiers or Access Specifiers in a class are used to set
the accessibility of the class members.
• There are 3 types of access modifiers available in C++
– Public
– Private
– Protected
Public - The members declared as Public are accessible from
outside the Class through an object of the class.
Protected - The members declared as Protected are accessible
from outside the class BUT only in a class derived from it.
Private - These members are only accessible from within the
class. No outside Access is allowed.
Member Functions in Classes

• There are 2 ways to define a member function:


– Inside class definition
– Outside class definition

• To define a member function outside the class


definition we have to use the scope resolution ::
operator along with class name and function name.
• // C++ program to demonstrate function
• // declaration outside class • // Definition of printname using scope resolution
operator ::
• #include <bits/stdc++.h> • void student::printname()
• using namespace std; • {
• class student • cout << “Name is: " << name;
• { • }
• public: • int main() {
• string name; •
• int id; • student obj1;
• • obj1.name = "xyz";
• // printname is not defined inside class • obj1.id=15;
defination •
• void printname(); • // call printname()
• • obj1.printname();
• // printid is defined inside class • cout << endl;
defination •
• void printid() • // call printid()
• { • obj1.printid();
• cout << " Id is: " << id; • return 0;
• } • }
• }; Output:
Name is: xyz
Id is: 15
Accessing Object Members
• class sample • }
• { • };
• private: • int main()
• int a; • {
• void fun1() • sample s;
• { • s.a=1; Wrong, Private cannot be accessed in main()
• ….. • s.fun1(); Wrong, fun1() is private
• } • s.b=2; Right, b is public
• public: • s.fun2(); Right, fun2 is public
• int b; • a=3;
• void fun2() • b=4; Without objects

• { • fun2();
• ….. • }
Nested Member function
• A member function can be called by using its name inside another
member function of the same class is known as nesting of member
functions.
class rectangle
{
private:
float length;
float breadth;
public:
void get_data() { cin>>length>>breadth;}
voidshow_data(){cout<<“length”<<length<<“breadth”<<breadth<<“area=“<<
area(); }
int area()
{ return length*breadth;}
};
Inline Member Function
• A member function that is defined inside its class member list is
called an inline member function. Member functions containing a
few lines of code are usually declared inline.
class rectangle
{
private:
float length;
float breadth;
public:
void get_data() { cin>>length>>breadth;}
void show_data();
};
inline void rectangle :: show_data(void)
{
cout<<“length”<<length<<“breadth”<<breadth;
}
Pointers

• int main()
• { Output
• int *pnum 2
2
• char *pch; 2
• float *pfnum; 2
• double *pdnum;
• cout<<sizeof(pnum);
• cout<<sizeof(pch);
• cout<<sizeof(pfnum);
• cout<<sizeof(pdnum);
Dereferencing Pointers
int main()
{
int num,*pnum;
pnum=&num;
cout<<“Enter the number”; Output
cin>>num; Enter the number : 15
15
cout<<*pnum; FFDC
cout<<&num;
}
Rules for Pointer Operations
• A pointer variable can be assigned the address of another
variable (of the same type).
• A pointer variable can be assigned the value of another
pointer variable (of the same type).
• A pointer variable can be initialized with a NULL (or 0) value.
• Prefix and postfix increment and decrement operators can be
applied on a pointer variable.
• An integer value can added or subtracted from a pointer
variable.
• A pointer variable cannot be multiplied by a constant.
• A pointer variable cannot be added to another pointer
variable.
• A pointer variable can be compared with another pointer
variable of the same type using relational operators.
Null Pointer
• Null pointer which is a special pointer value that is known not to
point anywhere.
• Null pointer does not point to any valid memory address.
int *ptr=NULL
• You can check whether a given pointer variable stores address of
some variable or contains a null
If (ptr==NULL)
{
Sts block;
}
• You may also initialize a pointer as a NULL pointer by using a
constant 0.
int ptr;
ptr=0;
Pointers to Pointers
• C++ use pointers that point to pointers. The pointers in turn
point to data (or even to other pointers).
• To declare pointers to pointers add an asterisk (*) for each
level of reference.
int x=10;
int *px;
x px ppx
int **ppx;
10 1002 2004
px=&x;
1002 2004 4008
ppx=&px;
Cout<<**ppx;
Constant Pointer
• A constant pointer is a pointer that cannot change the
address it is storing.
• Once assigned the address of a variable the constant
pointer cannot be made to point to any other variable.
• The value at the address pointed by the constant
pointer may be changed.
datatype *const ptr_var = init address
• Char *const ptr = &c;
• *ptr =‘B’
UML diagram Introduction
• Unified Modeling Language (UML) is a general purpose
modelling language. The main aim of UML is to define a standard
way to visualize the way a system has been designed.
• UML is not a programming language, it is rather a visual
language. We use UML diagrams to portray the behavior and
structure of a system.
Diagrams in UML can be broadly classified as:
• Structural Diagrams – Capture static aspects or structure of a
system. Structural Diagrams include: Component Diagrams, Object
Diagrams, Class Diagrams and Deployment Diagrams.
• Behavior Diagrams – Capture dynamic aspects or behavior of the
system. Behavior diagrams include: Use Case Diagrams, State
Diagrams, Activity Diagrams and Interaction Diagrams.
Object Oriented Concepts Used in UML
• Class – A class defines the blue print i.e. structure and
functions of an object.
• Objects – Objects help us to decompose large systems and
help us to modularize our system.
• An object is the fundamental unit (building block) of a system
which is used to depict an entity.
• Inheritance – Inheritance is a mechanism by which child
classes inherit the properties of their parent classes.
• Abstraction – Mechanism by which implementation details
are hidden from user.
• Encapsulation – Binding data together and protecting it from
the outer world is referred to as encapsulation.
• Polymorphism – Mechanism by which functions or entities
are able to exist in different forms.
UML Diagrams
UML includes the following nine diagrams
• Class diagram
• Object diagram
• Use case diagram
• Sequence diagram
• Collaboration diagram
• Activity diagram
• Statechart diagram
• Deployment diagram
• Component diagram
The building blocks of UML can be defined as
• Things
• Relationships
• Diagrams
Things
Things are the most important building blocks of
UML. Things can be −
• Structural
• Behavioral
• Grouping
• Annotational
Structural Things
• Structural things define the static part of the model. They represent the physical and conceptual
elements.
• Class − Class represents a set of objects having similar responsibilities.

• Interface − Interface defines a set of operations, which specify the responsibility of a class.

• Collaboration −Collaboration defines an interaction between elements.

• Use case −Use case represents a set of actions performed by a system for a specific goal.

• Component −Component describes the physical part of a system.

• Node − A node can be defined as a physical element that exists at run time.
Behavioral Things
• Interaction − Interaction is defined as a behavior that consists
of a group of messages exchanged among elements to
accomplish a specific task.

• State machine − State machine is useful when the state of an


object in its life cycle is important. It defines the sequence of
states an object goes through in response to events. Events are
external factors responsible for state change
Grouping Things & Annotational Things
• Grouping things can be defined as a mechanism to
group elements of a UML model together.
• Package − Package is the only one grouping thing
available for gathering structural and behavioral
things.

• Annotational things can be defined as a mechanism


to capture remarks, descriptions, and comments of
UML model elements.
Relationship
• It shows how the elements are associated with each other and
this association describes the functionality of an application.
Dependency
• Dependency is a relationship between two things in which
change in one element also affects the other.
Association
• Association is basically a set of links that connects the
elements of a UML model. It also describes how many objects
are taking part in that relationship.
Generalization
• Generalization can be defined as a relationship which connects
a specialized element with a generalized element. It
basically describes the inheritance relationship in the world
of objects.
Realization
• Realization can be defined as a relationship in which
two elements are connected. One element describes
some responsibility, which is not implemented and
the other one implements them. This relationship
exists in case of interfaces.
Class Diagram
• UML class is represented by the following figure. The diagram is divided
into four parts.
• The top section is used to name the class.
• The second one is used to show the attributes of the class.
• The third section is used to describe the operations performed by the class.
• The fourth section is optional to show any additional components.
• Classes are used to represent objects. Objects can be anything having
properties and responsibility.
Object Notation
• The object is represented in the same way as the
class. The only difference is the name which is
underlined.
• As the object is an actual implementation of a class,
which is known as the instance of a class. Hence, it
has the same usage as the class.
Aggregation implies a relationship where the child can exist
independently of the parent. Example: Class (parent) and Student
(child). Delete the Class and the Students still exist.

Composition implies a relationship where the child cannot exist


independent of the parent. Example: House (parent) and Room
(child). Rooms don't exist separate to a House.
Generalization vs Specialization
• Generalization is a mechanism for combining similar classes of objects
into a single, more general class. Generalization identifies commonalities
among a set of entities. The commonality may be of attributes, behavior, or
both.
• A superclass has the most general attributes, operations, and relationships
that may be shared with subclasses. A subclass may have more specialized
attributes and operations.
• Specialization is the reverse process of Generalization means creating new
sub classes from an existing class.
Abstraction
• Abstraction is specifying the framework and hiding the
implementation level information.
• Abstraction reduces the complexity by hiding low level details.
• Example: A wire frame model of a car.
• Abstract classes cannot have any objects.
• Exist only for other classes to inherit from it.
• Concrete classes are used to instantiate objects.
Multiplicity (Cardinality)
• Place multiplicity notations near the ends of an association.
• These symbols indicate the number of instances of one class
linked to one instance of the other class.
• For example, one company will have one or more employees,
but each employee works for just one company.
UML class diagram – Online Shopping
UML class diagram – Banking System
• Draw a class diagram for Library Management
System.

• Draw a class diagram for online examination system.


Static
• Static elements are allocated storage only once in a
program lifetime in static storage area.

• They have a scope till the program lifetime.

Static Keyword can be used with following,


– Static variable in functions
– Static Class Objects
– Static member Variable in class
– Static Methods in class
Static Variables inside Functions
• Static variables when used inside function are initialized only
once, and then they hold their value even through function
calls.
• These static variables are stored on static storage area , not in
stack.
Static Class Objects
• Static keyword works in the same way for class objects too.

• Objects declared static are allocated storage in static storage


area, and have scope till the end of program.

• Static objects are also initialized using constructors like other


normal objects.

• Assignment to zero, on using static keyword is only for


primitive data types, not for user defined data types.
Output
Constructor
END
destructor
Static Data Member in Class
• Static data members of class are those members which are
shared by all the objects.

• Static member variables (data members) are not initialized


using constructor, because these are not dependent on object
initialization.

• Once the definition for static data member is made, user


cannot redefine it. Though, arithmetic operations can be
performed on it.
Output
1
Static Member Functions

• These functions work for the class as whole rather


than for a particular object of a class.

• It can be called using an object and the direct


member access . operator.

• But, its more typical to call a static member function


by itself, using class name and scope
resolution :: operator.
Output
Static Member Function
Static Member Function
• These functions cannot access ordinary data
members and member functions, but only static
data members and static member functions.

• It doesn't have any "this" keyword which is the


reason it cannot access ordinary members.
Constructor
A constructor is a special member function of a class which is
automatically invoked at the time of creation of an object to
initialize or construct the values of data members of the object.
Features of constructor
• Constructor has same name as the class itself.
• A constructor must be declared in the public section.
• Constructor should not be called explicitly because a constructor is
automatically invoked when an object of a class is created.
• A constructor never return any value.
• A constructor cannot be inherited or virtual.
• The address of a constructor cannot be referred to in programs.
• A constructor cannot be declared as static or const.
• Like normal function, constructor function can also be
overloaded.
• Like normal function, constructor function also have default
arguments.
Types of Constructors
Dummy Constructor (Do Nothing
Constructor)
• Dummy constructor which does not perform any action.
• Action means does not initialize any data member and thus
the variable acquire a garbage value.

Output
X=3938 (garbage value)
Default Constructors
• Default constructor is the constructor which doesn’t
take any argument. It has no parameters.

Output
a: 10
b: 20
Parameterized Constructors

• It is possible to pass arguments to constructors.

• Arguments help initialize an object when it is created.

• To create a parameterized constructor, simply add parameters


to it the way you would to any other function.

• When you define the constructor’s body, use the parameters


to initialize the object.
Output
X=10
Copy Constructor
• A copy constructor takes an object of the class as an
argument and copies data values of members of one object
into the values of members of another object.

• Since it takes only one argument it is also called one argument


constructor.

• The primary use of copy constructor is to create a new object


from an existing one by initialization.

• The copy constructor takes the reference to an object of the


same class as an argument.
Output
X=10
X=10
Dynamic Constructor
• These are the constructors in which memory for data
members is allocated dynamically.

• Dynamic constructor enables the program to allocate the right


amount of memory to data members of the object during
execution.

• This is beneficial when the size of the data members is not the
same each time the program is executed.

• The memory allocated to the data members is released when


the object is no longer required and when the object goes
out of scope.
Output
Enter the size of array: 5
Enter the elements: 1 2 3 4 5
12345
Destructor
• Like constructor a destructor is also a member
function that is automatically invoked.

• Job of destructor is to destroy the object.

• It deallocates the memory that is dynamically


allocated to the variable or perform other clean up
operations.
Features of Destructor
• The name of the destructor is same as that of class name but it
should preceded by the tilde symbol ~.
• Destructor is called when the object goes out of scope.
• It is called when the programmer explicitly deletes an object using
the delete operator.
• Like constructor, a destructor also declared in the public section.
• The order of invoking a destructor is the reverse of invoking a
constructor.
• Destructor do not take any arguments and thus cannot be
overloaded.
• A destructor does not return any value.
• A destructor must be specifically defined to free the resources such
as memory.
• The address of the destructor cannot be accessed in the program.
• Constructor or destructor cannot be inherited.
• Unlike constructors, destructor can be virtual.
Output
constructor called for object with value: 1
constructor called for object with value: 2
constructor called for object with value: 3
Destructor called for object with value: 3
Destructor called for object with value: 2
Destructor called for object with value: 1
Friend Function
• If a function is defined as a friend function then, the private
and protected data of a class can be accessed using
the function.

• The complier knows a given function is a friend function by


the use of the keyword friend.

• For accessing the data, the declaration of a friend function


should be made inside the body of the class (can be anywhere
inside class either in private or public section) starting with
keyword friend.

• Friend function help implement data encapsulation in c++.


• Declaration of friend function
Features of Friend Function
• Friend function is the normal external function that is given
special access privileges.
• The friend declaration can be placed either in the private or
public section.
• A friend function of the class can be a member and friend of
some other class.
• A friend function of one class can be friend of another class.
• Since friend function are non members of the class they do not
require this pointer.
• The keyword friend is placed only in the function declaration
and not in the function definition.
• A friend function can access the class members directly using
the object name and dot operator followed by the specific
member.
• A function can be declared as friend in any number of classes.
Friend function

Output
Mean value: 32.5
Friend Class

Output
Sum:55
Use Case diagram
• The purpose of use case diagram is to capture the dynamic aspect of a
system.
• Used for describing a set of user scenarios
• Mainly used for capturing user requirements
• Work like a contract between end user and software developers.
• Use case Core components
• Actors: A role that a user plays with respect to the system, including
human users and other systems. e.g.,inanimate physical objects (e.g. robot);
an external system that needs some information from the current system.
• Use case: A set of scenarios that describing an interaction between a user
and a system, including alternatives.

• System boundary: Rectangle diagram representing the boundary


between the actors and the system.
Use Case Diagram(core relationship)
• Include: a dotted line labeled <<include>> beginning at base
use case and ending with an arrows pointing to the include use
case. The include relationship occurs when a chunk of
behavior is similar across more than one use case. Use
“include” in stead of copying the description of that behavior.
<<include>>

• Extend: a dotted line labeled <<extend>> with an arrow toward the


base case. The extending use case may add behavior to the base use case.
The base class declares “extension points”.
<<extend>>
Use Case Diagrams

Boundary Use Case


Actor
Library System

Borrow
Employee
Client

Order Title

Fine Remittance

Supervisor

• A generalized description of how a system will be used.


• Provides an overview of the intended functionality of the system
Use Case Diagrams(cont.)

(TogetherSoft, Inc)
Class and objects
• class student "<<endl;
• { • cin >> total;
• private: • perc=(float)total/500*100;
• char name[30]; • }
• int rollNo; • //member function definition, outside of
• int total; the class
• float perc; • void student::putDetails(void){
• public: • cout << "Student details:\n";
• //member function to get student's • cout << "Name:"<< name<<endl << "Roll
details Number:" << rollNo <<endl<< "Total:"
• void getDetails(void); << total<<endl << "Percentage:" <<
perc<<endl;
• //member function to print student's • }
details
• void putDetails(void);
• }; • int main()
• //member function definition, outside of • {
the class • student std; //object creation
• void student::getDetails(void){ • std.getDetails();
• cout << "Enter name: " <<endl; • std.putDetails();
• cin >> name; • return 0;
• cout << "Enter roll number: "<<endl; • }
• cin >> rollNo;
• cout << "Enter total marks outof 500:
Output
Enter name: Ram
Enter roll number: 123
Enter total marks out of 500: 455
Student details:
Name: Ida
Roll Number:123
Total:455
Percentage:91
GCD of two numbers

Output
62 8
GCD of 62 and 8 is 2

You might also like