Log In Register

Units


Command Line Arguments - Questions and Answers

 

Practice these Command Line Arguments under C Programming walk-in interview Questions/ examination questions with best tricks and short cuts with solution. Student (candidate) who want to crack the walk in interview, competitive exams and want to find short cuts and tricks to solve questions on Command Line Arguments for following purpose.


– Anyone who is wishing to increase their perfect knowledge of Command Line Arguments of C Programming.
– Anyone who is preparing for aptitude test and increase his in depth aptitude knowledge C Programming specifically Command Line Arguments.
– Anyone who is preparing for interviews (competitive examinations, govt examinations and bank examinations, off-campus or on campus interviews, walk-in interview and company interviews) having questions on Command Line Arguments under C Programming.

– Anyone who is preparing for aptitude test or competitive exam or entrance exam.
– Anyone who is preparing for entrance examinations and other competitive examinations.
– All Experienced, Freshers and Students.

Here is list of Questions and Answers covering all key area of  Command Line Arguments topic of C Programming:

 

1.

What is the output of this C code (if run with no options or arguments)?

  1.     #include <stdio.h>
  2.     int main(int argc, char *argv[])
  3.     {
  4.         printf("%d\n", argc);
  5.         return 0;
  6.     }

Answer: Option C

Explanation:

2.

The second (argument vector) in command line arguments is

Answer: Option A

Explanation:

3.

What is the output of this C code (run without any commandline arguments)?

  1.     #include <stdio.h>
  2.     int main(int argc, char *argv[])
  3.     {
  4.         while (argc--)
  5.         printf("%s\n", argv[argc]);
  6.         return 0;
  7.     }

Answer: Option C

Explanation:

4.

What would be the output if we try to execute following segment of code (assuming the     following input “cool brother in city”)?

  printf(“%s\n”, argv[argc]);

Answer: Option D

Explanation:

5.

What is the output of this C code (run without any command line arguments)?

  1.     #include <stdio.h>
  2.     int main(int argc, char *argv[])
  3.     {
  4.         while (*argv  !=  NULL)
  5.         printf("%s\n", *(argv++));
  6.         return 0;
  7.     }

Answer: Option C

Explanation:

6.

What type of array is generally generated in Command-line argument?

Answer: Option B

Explanation:

7.

What is the output of this C code(run without any command line arguments)?

  1.     #include <stdio.h>
  2.     int main(int argc, char *argv[])
  3.     {
  4.         while (argv != NULL)
  5.         printf("%s\n",  *(argv++));
  6.         return 0;
  7.     }

Answer: Option D

Explanation:

8.

In linux, argv[0] by command-line argument can be occupied by

Answer: Option D

Explanation:

9.

The first argument in command line arguments is

Answer: Option C

Explanation:

10.

argv[0] in command line arguments, is

Answer: Option C

Explanation:

11.

What does argv and argc indicate in command-line arguments?
    (Assuming: int main(int argc, char *argv[]) )

Answer: Option C

Explanation:

12.

What is the output of this C code (run without any commandline arguments)?

  1.     #include <stdio.h>
  2.     int main(int argc, char *argv[])
  3.     {
  4.         printf("%s\n", argv[argc]);
  5.         return 0;
  6.     }

Answer: Option D

Explanation:

13.

What is the output of this C code (run without any commandline arguments)?

  1.     #include <stdio.h>
  2.     int main(int argc, char *argv[])
  3.     {
  4.         while (*argv++ != NULL)
  5.         printf("%s\n", *argv);
  6.         return 0;
  7.     }

Answer: Option B

Explanation:

14.

A program that has no command line arguments will have argc

Answer: Option B

Explanation:

15.

The index of the last argument in command line arguments is

Answer: Option A

Explanation: