How to use Recursive Function Example in C++ programming Code of GCD calculating
1.
What will be the output of this code?
int GCD
(int A, int B)
{
cout << "A : " <<A
<< " B : " <<B << endl;
if (A > B)
{
A = A - B;
return GCD (A, B);
}
else if (A < B)
{
B = B - A;
return GCD (A, B)
}
else if (A = B)
{
return A;
}
}
int
main()
{
int A = 45, B = 55;
cout << "The GCD is "
<< GCD(A,B) << endl;
system("pause");
return 0;
}
|
0 comments:
Post a Comment