Top

Command Line Arguments

41.

What will be the output of the program (sample.c) given below if it is executed from the command line?
cmd> sample friday tuesday sunday

/* sample.c */
#include

int main(int sizeofargv, char *argv[])
{
    while(sizeofargv)
        printf("%s", argv[--sizeofargv]);
    return 0;
}

 

Answer: C

No answer description available for this question.

Enter details here

Answer: A

Command line arguments are the arguments that passed to the main function when the program is starting its execution.

Enter details here

43.

What will be the output of the program (myprog.c) given below if it is executed from the command line?
cmd> myprog one two three

/* myprog.c */
#include
#include

int main(int argc, char **argv)
{
    int i;
    for(i=1; i<=3; i++)
        printf("%u\n", &argv[i]);
    return 0;
}

If the first value printed by the above program is 65517, what will be the rest of output?

Answer: B

No answer description available for this question.

Enter details here

44.

Even if integer/float arguments are supplied at command prompt they are treated as strings.

Answer: A

No answer description available for this question.

Enter details here

45.

What is the output of this C code?

#include 
    void foo(int*);
    int main()
    {
        int i = 10;
        foo((&i)++);
    }
    void foo(int *p)
    {
        printf("%d\n", *p);
    }

 

Answer: C

No answer description available for this question.

Enter details here

46.

Which of the following gives the name of the program if the second parameter to the main fucntion is char **argv?

Answer: C

The first string in the list of command line arguments represents the name of the program which can be accessed by using argv[0].

Enter details here

Answer: D

All of the statements about the second parameter is correct. It is the collection of character pointers which of which the first represents the name of the program file.

Enter details here

48.

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

Answer: D

No answer description available for this question.

Enter details here

49.

What will be the output of the program

#include
void fun(int);

int main(int argc)
{
    printf("%d ", argc);
    fun(argc);
    return 0;
}
void fun(int i)
{
    if(i!=4)
        main(++i);
}

 

Answer: B

No answer description available for this question.

Enter details here

Answer: B

The second argument of the main() function represents the list of command line arguments that are passed.

Enter details here

Loading…
Tags: Command Line Arguments Questions and Answers || Command Line Arguments MCQ Questions and Answers || Command Line Arguments GK Questions and Answers || Command Line Arguments GK MCQ Questions || Command Line Arguments Multiple Choice Questions and Answers || Command Line Arguments GK || GK on Command Line Arguments || C Programming Questions and Answers || C Programming MCQ Questions and Answers || C Programming GK Questions and Answers || GK on C Programming