Proxy > Gmail Facebook Yahoo!

Program to find the GCD of a number using C++



 
#include<iostream>
 
void main()
{
 using namespace std;
 
 int num1,num2;
 cout<<"Enter 1st no. ";
 cin>>num1;
 cout<<"Enter 2nd no. ";
 cin>>num2;
 while(num1!=num2)
 {
  if(num1>num2)
  {
   num1 = num1-num2;
  }
  else
  {
   num2 = num2-num1;
  }
 }
 
 cout<<"GCD is = "<<num1;
 cin.get();
}


Responses

0 Respones to "Program to find the GCD of a number using C++"


Send mail to your Friends.  

Expert Feed

 
Return to top of page Copyright © 2011 | My Code Logic Designed by Suneel Kumar