I'm just getting my feet wet with C++ and could do with some pointers (no pun meant) with the logic of programming..
I'm trying to write a very basic and small program to work out the Higest Common Factor of 2 int numbers, as entered by the user.
Please don't laugh, but here is my effort, which does not work.
I'm looking for your comments on where I've gone wrong...
Code:
#include <iostream.h>
#include <iomanip.h>
int main()
{
int num1, num2, factor=0, factor1, factor2;
cout<<"Enter the first number ";
cin>>num1;
cout<<"Enter the second number ";
cin>>num2;
do
{
factor1=num1%factor;
factor2=num2%factor;
factor++;
}
while(num1%factor!=0 && num2%factor!=0);
cout<<"Factor is "<<factor;
return 0;
}
Sorry if this is a muppet question.
Hope you can 'show me the light'..
Cheers fellas (and any ladies, to be PC)
[code][/code]tagged by Salem