This C Program computes first N fibonacci numbers using command line arguments.

Here is source code of the C Program to compute first N fibonacci numbers using command line arguments. The C program is successfully compiled and run on a Linux system. The program output is also shown below.

`/*`

`* C Program to Compute First N Fibonacci Numbers using Command Line Arguments`

`*/`

`#include <stdio.h>`

`/* Global Variable Declaration */`

int first = 0;

int second = 1;

int third;

`/* Function Prototype */`

void rec_fibonacci(int);

void main(int argc, char *argv[])/* Command line Arguments*/

`{`

int number = atoi(argv[1]);

printf("%d\t%d", first, second); /* To print first and second number of fibonacci series */

rec_fibonacci(number);

printf("\n");

`}`

`/* Code to print fibonacci series using recursive function */`

void rec_fibonacci(int num)

`{`

if (num == 2) /* To exit the function as the first two numbers are already printed */

`{`

return;

`}`

third = first + second;

printf("\t%d", third);

first = second;

second = third;

`num--;`

rec_fibonacci(num);

`}`

$ cc arg6.c $ a.out 10 0 1 1 2 3 5 8 13 21 34

**Sanfoundry Global Education & Learning Series – 1000 C Programs.**

Here’s the list of Best Reference Books in C Programming, Data-Structures and Algorithms

If you wish to look at programming examples on all topics, go to C Programming Examples.