Thursday 18 April 2019

Program to Calculate GCD or HCF of Two Numbers in C++ (No STL)

// mail me @ mujtaba.aamir1@gmail.com for c++,python notes for free.....
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
int __gcd(int a,int b)
{
if(b==0)
return a;
return __gcd(b,a%b);
}
int main()
{
int a=12;
int b=6;
cout<<__gcd(a,b);
}

No comments:

Post a Comment

Amazon1Ads