Can someone write a quick program for me. The purpose of the program is to find the GCD(Greatest Common Denominator) of two integers that are inputed. All common denominators have to be displayed. Then at the end of the output, the greatest will be displayed. It will look something like this:
Common Denominators: 1,2,4
Greatest Common Denominator: 4
Read the rules... We will not code things for you, and this is 100% likely to be a homework assignment. We aren't just a forum that spits out your homework so you can get a good grade, this is a helping website. At least ATTEMPT to do your own work then we might consider helping you.
Well im sorry. Im new to this. Ill write what i can with what ive learned so far. I cant experiment with the program because i dont have the C++ program here at home. It is a school where i have Computer Science as a class.
Here's an idea of how you can do it :). Find the results generated by dividing the numerical input by a loop of values that decrement from the value until half of the numerical input. Make another loop that decrements a single unit from each of these results, if the result of the new loop ever turns up a value of 0, then you have yourself a denominator. Store the reults that return true to being a denomiator for all inputted numbers. Check the new results from both inputs against eachother to find the common denominators, find the highest common denominator.
cout<<"Please enter two integers"<<endl;
cout<<"Cannot use Negative Integers"<<endl;
cout<<"Please enter positive integers"<<endl;
should it look sumthing like that?
1. Please use code tags + indention
2. For checking input a do ... while can be used.
3. Where did you get that algoritmn from? It's not correct. Find a working algoritmn and convert it to C++.
The simplest but not fastest algoritmn is to keep subtracting the lowest number from the highest one until you get zero.
Then return the value of the former lowest number. (The former highest one became zero)