Command Line Arguments


  1. What will be the output of the following C code (run without any command line arguments)?
     #include <stdio.h>
    int main(int argc, char *argv[])
    {
    while (argc--)
    printf("%s\n", argv[argc]);
    return 0;
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: E

    main


  1. What will be the output of the following C code (if run with no options or arguments)?
    #include <stdio.h>
    int main(int argc, char *argv[])
    {
    printf("%d\n", argc);
    return 0;
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    1



  1. What is the index of the last argument in command line arguments?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: A

    argc – 1


  1. A program that has no command line arguments will have argc _________.











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    One



  1. What is argv[0] in command line arguments?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: B

    The name by which the program was invoked