TCS Coding Questions – 1
Ques. Sample Program to print all Integers using Command Line Arguments?
This program is written for TCS.
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”]
// Program to print all value of
// command line argument
// once we get the value from command
// line we can use them to solve our problem
#include <stdio.h> int main(int argc, char *argv[]) { int a,b; int i; if(argc<2) { printf("please use \"prg_name value1 value2 ... \"\n"); return -1; } for(i=1; i<argc; i++) { printf("arg[%2d]: %d\n",i,atoi(argv[i])); } return 0; }
[/code]
The video compilation for this program –
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
Need explanation for command line arguments.
Tcs Coding question