1) Which of the following syntax is correct for command-line arguments?

   a) int main(int var, char *argv[])
b) int main(char *arv[], int arg)
c) int main(char c,int v)
d) int main(int v,char c)

2) What does argv and argc indicate in int main(int argc, char *argv[]) ?

    a) argument constant, argument variable
b) argument count, argument vector
c) argument constant, argument vector
d) argument count, argument variable

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

   a) MultiDimensional Array
 b) Jagged Array
c) 2-Dimensional Array
d) Single Dimensional Array

4) The maximum length of the command-line arguments including the spaces is

   a)May vary from one OS to another
b)256 characters
c)Depends on the Number of arguments
d)128 characters

5) The index of the last argument in command line arguments is

   a) argc
b) argc * 2
c) argc – 1
d) argc + 1

6) What is the first argument of command line ?

   a)File Name
b)Program Designation
c)argument passed by user
   d)Program Name

7)What argv means in command line argument?

    a)Array of pointers
b)pointer to a character array
 c)Array of character pointers
d)Array of Strings

8) What will be the output of the following program if argument passed to command lines are : prog 1 4 2

#include<stdio.h>
int main(int argc, char *argv[])
{
    int j;
    j = argv[1] + argv[2] – argv[3];
    printf(“%d”, j);
    return 0;
}
a)Error
b)3
c)Garbage Value
d)None of these

Ans–> Here, argv[1], argv[2] and argv[3] are of type String. So, we have to convert String to integer before performing arithmetic operation.

9) What argv[0] and argv[1] denote in Command line Arguments ?

  a) Pointers to first two command line argument supplied.
b) File Name and pointer to first command line argument supplied.
c) Program Name and Pointer to the 1st argument.
d) None of these.

10) Which one of these is equivalent to argc ?

  a) Number of Arguments
b) Number of Arguments – 1
c) Number of Arguments + 2
d) Number of Arguments + 1 

11) What will be output of the following program  if argument passed to command lines are : prog 1 4 2

     #include<stdio.h>
     int main(int argc, char *argv[])
      {
             while(argc–)
                   printf(“%s\n”,argv[argc]);
            
        return 0;
      }

  a) 2 4 1
b) Garbage-value 2 4 1
c) Garbage-value  2 4 1 prog
d) Infinte Loop

12) What will be output of the following program  if argument passed to command lines are  : demo one two three

#include<stdio.h>
int main(int argc, char *argv[])
  {
       printf(“%c\n”,**+argv);
    
     return 0;
  }

 a) n
 b) o
c) t
d) Compile Time Error

Ans–> Here, char * argv[ ] denotes Array of Pointers. So, argv[ ] holds the address of the command line argument passed. ++argv denote the address of next location, which holds the address of the 2nd argument.
*++argv denote the value stored at that address i.e. the address of the 1st character of the 2nd argument and **++argv itself denote the character ‘o’ .

13) What will be output of the following program  if argument passed to command lines are  : demo friday

#include<stdio.h>
int main(int argc, char *argv[])
{
       printf(“%c”,*++argv[1]);
  
  return 0;
}

a) r
b) f
c) i
d) d

Ans–>argv[1] can be wriiten as *(argv+1), (argv+1) denote the address of next location, which holds the address of 2nd argument. Thus *(argv+1) or argv[1] denote the value stored at that address i.e. denote the address of 1st character of the 2nd Argument. ++argv[1] denote the address of 2nd character of the 2nd Argument. So *++argv[1] itself denote the character ‘r’ .