i think i also have to correct my main() . Am i right ( mind the bold )
.....
steps1 = 0;
gdc1 = gcdrecurs(a1,a2,&steps1);
printf("the gdc is %d and %d steps were needed using...
Type: Posts; User: johngav
i think i also have to correct my main() . Am i right ( mind the bold )
.....
steps1 = 0;
gdc1 = gcdrecurs(a1,a2,&steps1);
printf("the gdc is %d and %d steps were needed using...
i'n not sure i get what you mean .
steps1 points to an int that is initialised to zero
steps1=0 in function main
i
you meant what it expects in steps1 right ?
Well steps1 is supposed to count how many times the function is called ( by it self + 1 ) . So it should be an int passed by reference in order not...
sorry my mistake
i think it shoud expect an int since the final outcome should be a greatest common divisor
Thanks for replying
I have one more question for the first function
int gcdrecurs(int m,int n,int *steps1 )
{
int temp , r ;
Hi everyone
I have to write a c program that calculates the greatest common divisor of two positive numbers , using the euclides algorithm . I have to implement two functions , one that works...
thanks again for all the help!
Both those solutions though would be too much for my level . Considering that i'm a newbie , i would say that the answer is probably that the mistake the function...
no it's not .Its i<5 not i<=5
laser i'm missing your point !I'm a newbie remember ? :-)
I see your point Kbriggs .seems like a stupid exercise though no ? I mean how would this function not be wrong ? What would you change
laserlight , do you mean why is recursion used in this case? I don;t know
kbriggs i guess it is incremented after f calling and that's probably the reason it is indefinate. but how should it be?
laser , f is the name in both cases , so it is a reccuring function , so ? Ican't get any further
kbriggs the value is 1 isn't it ? , but that's not very helpful
KBriggs , no , it is an idefinat loop , i run it with dev++ and it prints n f() many many times till the execution window closes
laser , i agree that the comment is the key , but what would be a...
tab thanks for replying.
In order to see logical errors , there should be something asked like "this function is supposed to do "this" ..." , but there isn't .
Hello everyone
i 'm a newbie in c and i have this exercise :
--------------------------------------------------------------------------------
What the error in the following function ?
...
ok guys i get your point
so what if i change it a bit :
( 4>3 ) && ( x=2 )
would that be true ?
Meaning , if the very next line of code is
Hello all
I'm a novice both in c programming and this forum
this is a true or false question :
-----------------------------------------------------
The following exrpession assigns 2 in...