Answer to Question #11238 in C++ for Rajapaksha
#include<stdio.h>
int main(){
char array [50];
int i;
array[0]=0;
array[1]=1;
for(i=2;i<15;i++){
array[i]=array[i-1]+array[i-2];
}
for(i=0;i<15;i++){
printf(" %d ",array[i]);
}
}
this is a my code for fabbonaci sequence...
outputs are 0 , 1, 1 ,2, 3,5, 8,13,21,34,55,89,-112,-23
up to 12th element sequence is correct,,bt other elements are wrong...plz help me...
thanks...
1
2012-07-05T07:28:25-0400
#include<stdio.h>
int main(){
int array [50]; //HERE you must use int type not char
int i;
array[0]=0;
array[1]=1;
for(i=2;i<15;i++){
array[i]=array[i-1]+array[i-2];
}
for(i=0;i<15;i++){
printf(" %d ",array[i]);
}
}
Need a fast expert's response?
Submit order
and get a quick answer at the best price
for any assignment or question with DETAILED EXPLANATIONS!
Learn more about our help with Assignments:
C++
Comments
Leave a comment