Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

recursive pseudocode

Posted on 1998-06-04
8
Medium Priority
?
1,003 Views
Last Modified: 2006-11-17
I have been asked by my tutor to code this pseudocode that outputs all of the intermediate as well as the final values of a Greatest Common Divisor. The inputs a and b are nonnegative numbers.

EUCLID(a,b)
                if b=0
                    then return a
                    else return EUCID(b, a mod b)

I am at a loss and would be grateful if anyone can help me.

Paul1
0
Comment
Question by:Paul1060498
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
8 Comments
 
LVL 22

Accepted Solution

by:
nietod earned 300 total points
ID: 1165268
It would be unethical for any of us to provide you with an answer.  But we can answer specific questions if you ask them.  If you attempt the problem and post your work, we can ofter suggestions and improvements.  but you have to give us something to work with.
0
 

Author Comment

by:Paul1060498
ID: 1165269
Yes, fair enough. This is the first time I have used this communication line.
I am working on other C++ tasks as well as a Software Engineering assignment.

 It was foolhardy to expect an answer. I will attempt and perhaps repost.

 I thank-you for your time.

Paul.
0
 
LVL 22

Expert Comment

by:nietod
ID: 1165270
You didn't have to accept that as "the" answer.  In fact you still don't.  When you have something (or have a specific question), post it as a comment here and I will be happy to help you.  

I check in about every 2 hours during day time hours in the USA.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:Paul1060498
ID: 1165271
Thank-you nietod. I am in London and am attempting a BTEC course in C++. The course is part-time, 3 hours on a Wednesday evening. The tutor is adequate and notes brief. I have no previous experience in coding so probably need extra help, but at this stage the resources are less than at under grad level where there seemed plenty.
Here is what I have got:

#include <iostream.h>
#include <math.h>

int main()
{
int array[2], *p;
p=array;
int i=0;

cout<<"Enter two nonnegative numbers: "<<endl;
for (i=0;i<2;i++)
{
cin>>array[i]; //I haven't included proviso to check +ve yet
}
while(*p++)
{
cout<<p;  //This outputs the two numbers input plus almost two lines of }  //numbers(???).  I want to find the largest of the two input and could use
//eg if(x>y)
          return x;
          else
          return y;

I wanted to assign pointers to the array eg array[0], *x; and array[1], *y;
- cannot work this out.

If I could do that I wanted to work out which is the largest - if one was zero then the other would be the GCD.

If x
0
 

Author Comment

by:Paul1060498
ID: 1165272
I appear to have run out of room. Here goes again.

If x
0
 

Author Comment

by:Paul1060498
ID: 1165273
I appear to have run out of room. Here goes again.

If x
0
 
LVL 22

Expert Comment

by:nietod
ID: 1165274
I am confussed (hopefully that doesn't make two of us).  Is the above code for the EUCLID() algorithm?  It doesn't seem like it.  It could be to get information for running the euclid algorithm,.  Is that it?

Its such a mess, I'm not sure where to begin.  

Lets start with some questions, rather than some answers (because I have questions, and no answers)

What are you hopping to do with the array called "array"?  
and what about the pointer p?

If you are having trouble posting comments here.  (It seems like it fromt he last two)  E-mail me the code at nietod@theshop.net.

But lets start with an explanation of what your goal is first, because I'm rather lost.
0
 

Author Comment

by:Paul1060498
ID: 1165275
Thank-you for your reply. I am going to swop over to E-mail where there may be more room to finish what I wanted to say.
See you there.

Paul.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question