HSC Science (Computer Science) 12th Board ExamMaharashtra State Board
Share

# Impliment class GCD which have member function (a/c), which calculate greatest common divisor of two number entered during program execution. Print( ) will Print GCD of two number. - HSC Science (Computer Science) 12th Board Exam - Computer Science 1

#### Question

Impliment class GCD which have member function (a/c), which calculate greatest common divisor of two number entered during program execution. Print( ) will Print GCD of two number.

#### Solution

#include<iostream.h>
class gcd
{
int a, b;
public :
void print ( );
};
void gcd :: print (void)
{
cin >> a >> b;
while (a ! = b)
{
if (a > b)
a – = b;
if (b>a)
b – = a;
}
cout << a;
void main ( )
{
gcd obj;
obj.print ( );
}
Is there an error in this question or solution?

#### APPEARS IN

2016-2017 (March) (with solutions)
Question 5.2.1 | 5.00 marks
Solution Impliment class GCD which have member function (a/c), which calculate greatest common divisor of two number entered during program execution. Print( ) will Print GCD of two number. Concept: C++ Programming.
S