Advertisements
Advertisements
प्रश्न
Write a program in C++ to find Greatest Common Divisor (GCD) of two inputted number.
कोड लेखन
उत्तर
#include<iostream·h>
void main()
{
int a, b, i;
count <<"Enter Two Numbers";
cin >>a>>b;
int gcd = 1, min;
if (a > b)
{
min = a;
}
else
min = b;
for (i = 1, i<=min; i++)
{
if (a % i == 0 && b % i == 0)
gcd = i;
}
cout <<"GCD="<<gcd;
}
shaalaa.com
या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
2023-2024 (March) Official