Consider the following code.

Consider the following code. Correct Answer ./simple

The correct answer is option 1.

Concept:

Command-line arguments are given after the name of the program in the command-line shell of Operating Systems. To pass command line arguments, we typically define main() with two arguments: the first argument is the number of command-line arguments and the second is the list of command-line arguments.

Explanation:

Here command-line arguments are  /simple hello world

Two arguments:

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

Following Are The Command Line Arguments Passed:

argv: ./simple

argv: hello

argv:  world

Hence the correct answer is ./simple.

Additional Information Properties of Command-Line Arguments:

  • They are passed to the main() function.
  • They are parameters/arguments supplied to the program when it is invoked.
  • They are used to control programs from outside instead of hard coding those values inside the code.
  • argv is a NULL pointer.
  • argv holds the name of the program.
  • argv points to the first command-line argument and argv point to the last argument.

Related Questions