Write a Program Fibonacci Series Using Command Line Arguments

C Programming Language / Command Line Arguments

2991

Program:

#include<stdio.h>
#include<stdlib.h>

int main (int argc, char *argv[]) 
{

    int n, first = 0, second = 1, next, c;
  
    n = atoi (argv[1]);
  
 
    printf ("These are %d values in Fibonacci series are by atnyla:-\n",n);
  
    for (c = 0; c < n; c++)
    {
        if (c <= 1)
	      next = c;
        else
		{
	        next = first + second;
	        first = second;
	        second = next;
        }
    
    printf ("%d\n", next);
    
        
    }
  
  return 0;
}

Output:

10

These are 10 values in Fibonacci series are by atnyla:-
0
1
1
2
3
5
8
13
21
34


Explanation:

Nope

This Particular section is dedicated to Programs only. If you want learn more about C Programming Language. Then you can visit below links to get more depth on this subject.