Top

Command Line Arguments

51.

To use command line arguments in C++, how many parameters are passed to the main function?

Answer: B

2 arguments are needed to be passed to main() function while using command line arguments. The first one represents a number of strings in the argument list and the second list represents the list of string arguments.

Enter details here

52.

What is the output of this C code?

#include 
    int main()
    {
        int *ptr, a = 10;
        ptr = &a;
        *ptr += 1;
        printf("%d,%d/n", *ptr, a);
    }

 

Answer: D

No answer description available for this question.

Enter details here

Answer: A

No answer description available for this question.

Enter details here

54.

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 argc, char *argv[])
{
    printf("%c", **++argv);
    return 0;
}

 

Answer: B

No answer description available for this question.

Enter details here

55.

What will be the output of this program ?

Answer: A

No answer description available for this question.

Enter details here

56.

What is the output of this C code?

#include 
    int *f();
    int main()
    {
        int *p = f();
        printf("%d\n", *p);
    }
    int *f()
    {
        int *j = (int*)malloc(sizeof(int));
        *j = 10;
        return j;
    }

 

Answer: A

No answer description available for this question.

Enter details here

57.

Which of the following is correct about the first parameter of the main function?

Answer: D

All of the statements about the first parameter is correct. The first parameter is of non-negative integer type and stores the count of command line arguments.

Enter details here

58.

What is the output of this C code?

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

 

Answer: A

No answer description available for this question.

Enter details here

59.

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

Answer: C

No answer description available for this question.

Enter details here

60.

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

int main(int argc, char **argv)
{
    printf("%c\n", **++argv);
    return 0;
}

 

Answer: C

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