Home / Programs / Write a Program Fibonacci Series Using Command Line Arguments
🚀 Programming Example

Write a Program Fibonacci Series Using Command Line Arguments

👁 2,610 Views
💻 Practical Program
📘 Step Learning
This is a program of Fibonacci Series using Command Line Arguments

💻 Program Code

#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;
}

                        

🖥 Program Output

10

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



                            

📘 Explanation

Nope
📚 Learning Subject

Master Programming Through Practical Examples

Improve your coding logic, problem-solving skills and programming confidence by practicing real-world examples with explanations.

🎯 How to learn from this example

First understand the algorithm carefully. Then study the program line-by-line and compare it with the output. Finally, review the explanation section to strengthen your logic and programming understanding.

🔥 Practice suggestion

Rewrite the program without looking at the code. Modify values, conditions or logic and run it again. This helps improve confidence and strengthens coding skills much faster.