Advertisement Remove all ads

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. - Computer Science 1

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.

Advertisement Remove all ads

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 ( );
}
Concept: C++ Programming
  Is there an error in this question or solution?
Advertisement Remove all ads

APPEARS IN

Advertisement Remove all ads
Advertisement Remove all ads
Share
Notifications

View all notifications


      Forgot password?
View in app×