C Programming – Command Line Arguments

C Programming - Command Line Arguments

Question 1
What does argv and argc indicate in command-line arguments?     (Assuming: int main(int argc, char *argv[]) )
A
argument count, argument variable
B
argument count, argument vector
C
argument control, argument variable
D
argument control, argument vector
Question 2
 Which of the following syntax is correct for command-line arguments?
A
int main(int var, char *varg[])
B
int main(char *argv[], int argc)
C
int main() { int argv, char *argc[]; }
D
Both (a) and (b)
Question 3
 In linux, argv[0] by command-line argument can be occupied by
A
./a.out
B
./test
C
./fun.out.out
D
All of the mentioned
Question 4
 What type of array is generally generated in Command-line argument?
A
Single dimension array
B
2-Dimensional Square Array
C
Jagged Array
D
2-Dimensional Rectangular Array
Question 5
 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]);
A
(null)
B
City
C
In
D
Segmentation Fault
Question 6
The first argument in command line arguments is
A
The number of command-line arguments the program was invoked with;
B
A pointer to an array of character strings that contain the arguments
C
Nothing
D
Both a & b
Question 7
The second (argument vector) in command line arguments is
A
The number of command-line arguments the program was invoked with;
B
A pointer to an array of character strings that contain the arguments,one per string.
C
Nothing
D
Both a & b
Question 8
 argv[0] in command line arguments, is
A
The name by which the program was invoked
B
The name of the files which are passed to the program
C
Count of the arguments in argv[] vector
D
Both a & b
Question 9
 A program that has no command line arguments will have argc
A
Zero
B
Negative
C
One
D
Two
Question 10
The index of the last argument in command line arguments is
A
argc – 2
B
argc + 1
C
argc
D
argc – 1
Question 11
What is the output of this C code (if run with no options or arguments)?
    #include 
    int main(int argc, char *argv[])
    {
    printf("%d\n", argc);
    return 0;
    }
A
0
B
1
C
Depends on the platform
D
Depends on the compiler
Question 12
What is the output of this C code (run without any commandline arguments)?
        #include 
        int main(int argc, char *argv[])
        {
        while (argc--)
        printf("%s\n", argv[argc]);
        return 0;
        }
A
Compile time error
B
Executablefilename
C
Segmentation fault
D
Undefined
Question 13
What is the output of this C code (run without any commandline arguments)?
        #include 
        int main(int argc, char *argv[])
        {
        printf("%s\n", argv[argc]);
        return 0;
        }
A
Segmentation fault/code crash
B
Executable file name
C
Depends on the platform
D
Depends on the compiler
Question 14
What is the output of this C code (run without any commandline arguments)?
        #include 
        int main(int argc, char *argv[])
        {
        while (*argv++ != NULL)
        printf("%s\n", *argv);
        return 0;
        }
A
Segmentation fault/code crash
B
Executable file name
C
Depends on the platform
D
Depends on the compiler
Question 15
What is the output of this C code (run without any command line arguments)?
        #include 
        int main(int argc, char *argv[])
        {
        while (*argv  !=  NULL)
        printf("%s\n", *(argv++));
        return 0;
        }
A
Segmentation fault/code crash
B
Executable file name
C
Depends on the platform
D
Depends on the compiler
Question 16
What is the output of this C code(run without any command line arguments)?
        #include 
        int main(int argc, char *argv[])
        {
        while (argv != NULL)
        printf("%s\n",  *(argv++));
        return 0;
        }
A
Segmentation fault/code crash
B
Executable file name
C
Depends on the platform
D
Depends on the compiler       


Check Your Answers:

  1. B
  2. A
  3. D
  4. C
  5. A
  6. A
  7. B
  8. A
  9. C
10. D
11. B
12. B
13. A
14. A
15. B
16. A



SHARE

Unknown

  • Image
  • Image
  • Image
  • Image
  • Image
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment