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 –
- TCS Coding Questions – 1
- TCS Coding Questions – 2
- Area of a Triangle
- TCS Command Line Arguments – Fibonacci Series
- TCS Command Line Program to Swap two numbers
- TCS String Reversal Using Command Line Programming
- Greatest of Two Numbers using CLP
- LCM of Two Number using CLP
- Average of Two Numbers
- Sum of Digits of a number
- Binary to Decimal
- Decimal to Binary
- Factorial of a Number
- Square Root of Prime Number
- Armstrong Number
Login/Signup to comment
command Line