Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

FIBONACCI FIB PRINT

Name: Anonymous 2009-12-04 20:18

FIBONACCI FIB PRRINT

Write a program that prints out a list of fibonacci numbers in a language of your choice.


/*        I'm using C, you LISPing cretins.         /
/  Remember to use your hot, stripping [coed] tags */

#include <stdio.h>

fibonacci (int fibs)
{
    int count, big = 0, small = 1;
    for (count = 0; count <= fibs; count++)
    {
        printf("\n#%2d - %10d", count, big);
        big = big + small;
        small = big - small;
    }
}

main()
{
    int x;
    printf("Enter the highest fib that you want to see: ");
    scanf("%i", &x);
    fibonacci (x);
}

Your move.

Name: Anonymous 2009-12-04 21:49

>>13
warning: return type defaults to "int"

I guess you're right on that. To be fair, they use functions without return types all the time in K&R 2nd Edition, but I digress.


/*        I'm using C, you LISPing cretins.         /
/  Remember to use your hot, stripping [coed] tags */

#include <stdio.h>

void fibonacci (int fibs)
{
    int count, big = 0, small = 1;
    for (count = 0; count <= fibs; count++)
    {
        printf("\n#%2d - %10d", count, big);
        big = big + small;
        small = big - small;
    }
}

int main()
{
    int x;
    printf("Enter the highest fib that you want to see: ");
    scanf("%i", &x);
    fibonacci (x);
   
    return 0;
}
Better?

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List