TCS Ninja Command Line Programming Questions and Answers

Get all the questions asked Today in TCS here – 

TCS Ninja Live Questions Dashboard 

Get all the questions asked Today in TCS here – 

TCS Ninja Live Questions Dashboard 

Command Line Programming Questions with Solutions

Command Line Programming is really different from a General C Programming. On this page you will learn the theory on how to code using Command Line arguments in TCS.

First you must understand why Command Line Arguments are used in C. Instead of hard coding elements there is way to provide arguments from outside the program, for this which use command Line Programming.

The command line arguments are handled using main() function arguments where argc refers to the number of arguments passed, and argv[] is a pointer array which points to each argument passed to the program. Following is a simple example which checks if there is any argument supplied from the command line and take action accordingly −

#include 

int main( int argc, char *argv[] )  {

   if( argc == 2 ) {
      printf("The argument supplied is %s\n", argv[1]);
   }
   else if( argc > 2 ) {
      printf("Too many arguments supplied.\n");
   }
   else {
      printf("One argument expected.\n");
   }
}

When the above code is compiled and executed with single argument, it produces the following result.

$./a.out testing
The argument supplied is testing

When the above code is compiled and executed with a two arguments, it produces the following result.

$./a.out testing1 testing2
Too many arguments supplied.

When the above code is compiled and executed without passing any argument, it produces the following result.

$./a.out
One argument expected

It should be noted that argv[0] holds the name of the program itself and argv[1] is a pointer to the first command line argument supplied, and *argv[n] is the last argument. If no arguments are supplied, argc will be one, and if you pass one argument then argc is set at 2.

nt main(int argc, char *argv[]){

  1. argc – It is know as Argument Count and as clear from the name it stores the Count of number of Arguments.
  2. argv[] – Pointer, contains location of all the values(arguments).
  3. *argv[] – Array of values of all the arguments.
  4. They are parameters/arguments supplied to the program when it is invoked.

Summary

  1. Total Count of number of Arguments.
  2. All the values/pointer location of arguments stored in an array.

Now, you will need one more thing i.e. atoi();

  • atoi(); – Converts string into int and atoi(argv[i]); will give the value of argument at ith location in int type format.

Now you can use an int val = atoi(argv[i]); to store the value and then print it with printf(); function.

You can find coding questions here on the Coding Dashboard for TCS Ninja.

Candidate Experience for Command TCS Ninja

  • Name: Karthikeyan
  • Branch: Mechanical
  • College: JB Institute of Engineering and Technology
  • Type of Interview: Off-Campus(TNSLPP)

Student Interview

Coming from a Tier 3 college, I was not expecting many CS companies to visit our Campus and TCS was one of the big companies I was hoping to get selected into. I am a mechanical student. I received a mail one day that said, “TCS is conducting off campus drive for a pass out students of 2017.” The next best step for me was to apply for the off-campus interview. The placement was conducted through TNSLPP.

Though I practised all the previous year questions through PrepInsta, a little nervousness was there. PrepInsta provides many practice questions so that students can be clear about the concepts. It also assisted me with the interview process of TCS. The company puts complete interview into two levels – Online round and the Interview.

Online Round

My written exam was on 31st January 2018 and we got the result on 2nd February 2018. The written test had four sections-

  • Quantitative Aptitude (20 Questions – 40 Minutes)
  • Programming language efficiency (10 Questions – 20 Minutes)
  • Coding Round (1 Question – 20 Minutes)
  • Verbal English (10 Question – 10 Minutes)

It was lengthy and a bit tiring. I believe, 90 mins are not sufficient to appear for the entire test. After the online round, I was eagerly waiting for the next round, which was scheduled on 17th February 2018 at TCS Vydehi Bangalore.

Interview Round

In the interview round, there were three interviewers sitting in the same panel – Technical, Managerial, and HR.

  1. Technical

Due to time constraint, they were interviewing two candidates at one time. Can you imagine the situation, if the other person answers each question in a better way than you, you lose the opportunity? This made me quite nervous. They were asking about the basics of C programming, and I was like “sorry, I am from mechanical, so I don’t have any idea about C and all.“

Interviewer: Ohk, since you are joining an IT company, just try to write the logic.

Me: Ohk, I will try.

They asked me some logic, I just took my time and completed that.

Interviewer: Good.

Surprisingly, I got the logic right. I was still clueless, how I did that?

Also, he asked me about the SQL and database like primary/foreign key constraints and some basic questions.

  1. Managerial

The managerial section of the interview was better. I was asked about my projects here. I was asked about my interests. My views and ideas of technology were tested. My friends had a few questions from programming at this level. MR guy basically checks your attitude and behaviour.

Also, he asked, why IT? To which I answered, the sector is developing and requires more human involvement to understand and build better solutions. I believe, it will not only contribute towards my development but also will give an optimized direction to the developing techniques.

A few more questions from the interviewer were,

  • Which is better, design or manufacturing?
  • What is the diagram of stress-stain for mild steel?

The panellist of MR mostly focused on checking my communication skill. But, the interview process does not complete right here. He said, “I am done with my list of questions.” I was waiting for the HR to bring his

  1. HR

The HR panellist began with the first question as, “What do you know about TCS”? I answered the question well as it is the first thing to prepare before pursuing interview in a company. With my experience, I think one should attain significant information about the company before having to face the interview rounds.

Later, the HR started asking me about my college, ragging, profile, and other things. It was going long, and I probably enjoyed talking to the interviewer. And, the last word I heard from the opposite side was “Impressive.”

I along with other selected students got the offer letter on 19th February 2018.

Though TCS has an image of the mass recruiter, it is a complete myth. They had recruited only 23 students out of 250 who appeared for the interview. I would advise all the candidates to remain confident and be good with the basics.