![]() |
New Student With C++ Program
I need help with this program. I just started and I can't get it to work. Help:
Code:
#include <iostream> |
Re: New Student With C++ Program
Will you try to explain what you are trying to get yourself work out and what you are not able to ?
|
Re: New Student With C++ Program
This is basically what I have to do:
I had to declare x, y, temp, and remainder as integers. Then I have to write a C++ if statement to determine if x < y. It is necessary for me to "swap" these values. This requires a “temp” variable. if ( x < y) { temp = x; x = y; y = temp; } This will put x into a temp storage area. It will resets x = y. Now, I have to put x in y but it is gone. However, it is stored in temp! To initialize the remainder, I have to initialize it to some value, usually 0 or 1 but could be something else. I have to use something else. remainder = (x % y); This will give me the remainder after division of x by y. (Note, can’t use y = 0.) Now, in the “while loop”: while (remainder != 0) { x = y y = remainder; remainder = (x % y); } In a nutshell I have to come up with a while loop and if statement with these guidelines. I've tried but I can't get it to work. Once I set everything up I have to plug in the following values: x y Expected answer 1 1 2 2 5 5 20 20 2 10 10 2 36 48 252 108 1024 256 23,205 1,638 |
Re: New Student With C++ Program
So where is the problem.
Also I would suggest you read Hints before you make a post to help you in posting your queries and code in the post |
| All times are GMT +5.5. The time now is 05:02. |