Hi There, I Would like to ask for your help about two diferent programs that donīrun properly, one is using a recursive function, I must print the numbers of the Fibonacci Serie, and in the other I mustcreate a two dimensional array which prints under the main diagonal only 0,
here is the code for the first one;
Code:
int fibo (int);
void main(){
int a, d;
printf("How many Numbers shall it print? ");
scanf("%d", &a);
d=fibo (a);
printf("%d", d);
}
/*int fibo (int uno int f){
int b, c=0, d=1;
printf("1");
for(b=1; b<=f; b++){
c=c+d;
d=d+c;
printf(", %d, %d", c, d);
}*/
int fibo (int a){
int static uno=1;
if (a>=1)
uno=fibo(a);
printf("\n%d", uno);
if (a==0){
return 1;
}
else{
printf("\n%d ",uno);
return (uno+ (fibo(a-1)));
}
}
If Anyone Can help me at least giving me an Idea on how to make it work i would be very thankful, the main problem is that chen I call the fuction again, it should add a value for num equal to a number of the serie, and i thought y had it done when i placed, but it does nothing, actualyy it says it causes a failure in the internal battery or something like that, so any help will be well recieved.
THe other code is correct in logic, what happens is that every time I run it, it completely closes c++, and i have no Idea why, if anyone can copy it and run it to see if it is general or itīs only my computer, thanks, however, even a comment on why is it doing this could be very helpful.
ok, hereīs the code:
Code:
#include <stdio.h>
void main(){
int a, b, ren, col, mat[100][100];
printf("line ");
scanf("%d", &a);
printf("column ");
scanf("d", &b);
for( ren=0;ren<b;ren){
for (col=0; col<a;col++){
scanf("%d", &mat[ren][col]);
if (ren>col)
mat[ren][col]=0;
}
}
for( ren=0;ren<b;ren){
for (col=0; col<a;col++){
printf("%d", &mat[ren][col]);
}
printf("\n");
}
}
THANKS FOR TAKING THE TIME!!!!!!!