GCD of two numbers

 // Online C++ compiler to run C++ program online

#include <iostream>

using namespace std;

int main() {

    // Write C++ code here

    int a,b,c,d,i;

    cout<<"Enter sides 1 : ";

    cin>>a;    

    cout<<"Enter sides 2 : ";

    cin>>b;

    // cout<<"Enter sides 3 : ";

    //cin>>c;

    for ( i=1;i<a | i<b;i++){

        if (a%i==0 & b%i==0 ){

            d=i;

        }

    }

    cout<<d;

    return 0;

}

Comments

Popular posts from this blog

Sum of Even Numbers till N

Find the Runner-Up Score!

Print All Substrings