Tuesday, July 14, 2009

Write a C program to print Fibonacci series using arrays, Write a C program to determine the mean and standard

plse help me to understand these question and how to write a code in c programming

Write a C program to print Fibonacci series using arrays, Write a C program to determine the mean and standard
Here is a little sample that is directly lifted from the "MyCPlus" website. This will prompt for a number and then give the Fibonacci numbers.





#include %26lt;stdio.h%26gt;





int main(void) {


int n; /* The number of fibonacci numbers we will print */


int i; /* The index of fibonacci number to be printed next */


int current; /* The value of the (i)th fibonacci number */


int next; /* The value of the (i+1)th fibonacci number */


int twoaway; /* The value of the (i+2)th fibonacci number */





printf("How many Fibonacci numbers do you want to compute? ");


scanf("%d", %26amp;n);


if (n%26lt;=0)


printf("The number should be positive.\n");


else {


printf("\n\n\tI \t Fibonacci(I) \n\t=====================\n");


next = current = 1;


for (i=1; i%26lt;=n; i++) {


printf("\t%d \t %d\n", i, current);


twoaway = current+next;


current = next;


next = twoaway;


}


}


}


No comments:

Post a Comment