0 votes
438 views
in Programming by (98.9k points)
edited
Write an Object Oriented Program in C++, to find the GCD of two given numbers.

Given numbers are 225 , 45

1 Answer

0 votes
by (98.9k points)
selected by
 
Best answer

#include <iostream>

using namespace std;


int gcd(int a, int b) {

   if (b == 0)

   return a;

   return gcd(b, a % b);

}

int main() {

   int a = 225, b = 45;

   cout<<"GCD of TWO NUMBERS"<< a <<" and "<< b <<" is "<< gcd(a, b);

   return 0;

}

image

Related questions

Doubtly is an online community for engineering students, offering:

  • Free viva questions PDFs
  • Previous year question papers (PYQs)
  • Academic doubt solutions
  • Expert-guided solutions

Get the pro version for free by logging in!

5.7k questions

5.1k answers

108 comments

531 users

...