‹ Back to the paper
A class Gcd has been defined to find the Greatest Common Divisor of two integer numbers. Some of…
A class Gcd has been defined to find the Greatest Common Divisor of two integer numbers. Some of the members of the class are given below:
Class name: Gcd
Data member/instance variable:
num1: integer to store the first number
num2: integer to store the second number
Member functions/methods:
Gcd(): default constructor
void accept(): to accept the numbers
int gcd(int x, int y): return the GCD of the two numbers x and y using recursive technique
void display(): displays the result with an appropriate message
Specify the class Gcd, giving details of the Constructor, void accept(), int gcd(int, int), and void display(). Define the main() function to create an object and call the functions accordingly to enable the task.
Answer
No answer yet.
From ISC 2022 Computer Science - Specimen paper (Semester 2), Paper 1, question 6(ii).