I am writing a code to display the HCF(highest common factor) of a number. For those of you who dont know just google it.
i have come up with this piece of code
the code returns no valueCode:#include<iostream> #include<conio.h> using namespace std; main() { int a,a1,b,b1,x=0,y=0; cout<<"Enter two numbers :"; cin>>a>>b; for(a1=1;a1<=a;b1++) { if(a%a1==0) x=a1; for(b1=1;b1<=a;b1++) { if(b%b1==0) y=b1; } if(x==y) cout<<x<<","; } _getch(); }
why?