Fibonacci Series Program – Using Command Line Arguments

Ques. Write a Program Fibonacci Series Using Command Line Arguments for TCS?

Below is the code for Fibonacci Series Using Command Line Arguments for TCS preparation made easy.

It is highly advisable to go through Command Line Arguments Post before even looking at the code. Please study this for TCS and come back to this post later.

[code language=”cpp”]
#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 PrepInsta:-\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;

}
[/code]

Other TCS Coding Questions –

Summary
Review Date
Reviewed Item
Command Line Argument Fibonacci
Author Rating
51star1star1star1star1star

Prepare Better for Placement Papers