Friends, i have written a code for finding HCF but it does not work. please help me in improving this code.Thanks in advance.

using namespace std;
int main ()
int a,b,c,d,e,f,g,h;
cout<<"Please input two nnumbers:"<<endl;
if d==o
cout<<"The hcf is:"<<b<<endl;
if d>>0
if f==0
cout<<"The hcf is:"<<d,,endl;
if f>>0
if h==0
cout<<"The hcf is:"<<f<<endl;
if h>>0
cout<<"The Hcf could not be found out due to the some problems";
return 0;

Edited 6 Years Ago by WaltP: Added CODE Tags

1) Welcome to Daniweb. One of the first things you need to know about this board is that when you post code the boad will gobble up your indenting and other formatting and make your code very difficult to read unless you enclose it in code tags. The use of code tags involves placing [ code ] before your code and [ /code ] after your code, though take the spaces between the words code and /code out when using the tags.

2) Learn to be as specific as possible when requesting help. For example your question is about as specific as me saying "I don't feel good". Does the code not compile? compile but with errors? not run? run but gives you wrong output?

3) Avoid use of abbreviations. HCF and gcd are probably synonyms, but it would be better if you wrote out Highest Common Factor at least once to prove it is the same idea as greatest common denominator.

4) Look into loops instead of essentially writing the same code three times.

5) Your algorithm is reminiscent of Euclids algorithm which can be Googled to compare with your code.

This article has been dead for over six months. Start a new discussion instead.