TCS Coding Questions – 1

Ques. Sample Program to print all Integers using Command Line Arguments


Note: Please go through Command Line Arguments Post before preparing for these questions. The theory there  for TCS command line Program will help you in better understanding .

[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;
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;