Top

Command Line Arguments

1.

In linux, argv[0] by command-line argument can be occupied by _________

Answer: D

No answer description available for this question.

Enter details here

Answer: A

No answer description available for this question.

Enter details here

3.

Which of the following is correct to interpret Hello World as a single argument?

1. $ ./output 'Hello World'

2.  $ ./output Hello World

Answer: C

To interpret space separated words as single argument one can use single or double quotes.

Enter details here

4.

What is the output of this C code?

#include 
    void main()
    {
        int x = 0;
        int *ptr = &x;
        printf("%p\n", ptr);
        ptr++;
        printf("%p\n ", ptr);
    }

 

Answer: A

No answer description available for this question.

Enter details here

5.

What is the output of this C code?

#include 
    int main()
    {
        int i = 10;
        int *p = &i;
        foo(&p);
        printf("%d ", *p);
        printf("%d ", *p);
    }
    void foo(int **const p)
    {
        int j = 11;
        *p = &j;
        printf("%d ", **p);
    }

 

Answer: B

No answer description available for this question.

Enter details here

6.

What is the output of this C code?

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

 

Answer: A

No answer description available for this question.

Enter details here

Answer: B

One can use either single or double quotes to handle command line argument with spaces in-between. For example, ./output “Hello World” has 2 command line argument “./output” and “Hello World”.

Enter details here

8.

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

Answer: C

No answer description available for this question.

Enter details here

9.

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

/* myprog.c */
#include

int main(int argc, char *argv[])
{
    printf("%c", *++argv[1]);
    return 0;
}

 

Answer: A

No answer description available for this question.

Enter details here

10.

The first argument to be supplied at command-line must always be count of total arguments.

Answer: B

No answer description available for this question.

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