answersLogoWhite

0

I am going to assume you want a program to print out the Fibonacci series.

#include <stdio.h>

int main(int argc, char **argv)

{

if (argc < 2) {

printf("Usage: %s max\n", argv[0]);

return -1;

}

int a = 1, b = 1, c;

int max = atoi(argv[1]);

printf("%d %d ", a, b);

while (b < max) {

c = a + b;

a = b;

b = c;

if ((b <= max)) printf("%d ", b);

}

printf("\n");

return 0;

}

User Avatar

Wiki User

13y ago

What else can I help you with?