Top

Command Line Arguments

71.

What will be the output of the following C code (run without any command line arguments)?

#include 
    int main(int argc, char *argv[])
    {
        while (*argv  !=  NULL)
        printf("%s\n", *(argv++));
        return 0;
    }

 

Answer: B

No answer description available for this question.

Enter details here

72.

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

/* sample.c */
#include

int main(int argc, char *argv[])
{
    int i=0;
    i+=strlen(argv[1]);
    while(i>0)
    {
        printf("%c", argv[1][--i]);
    }
    return 0;
}

 

Answer: C

No answer description available for this question.

Enter details here

73.

What will be the output of the following C code?

#include
main()
{
    typedef int a;
    a b=2, c=8, d;
    d=(b*2)/2+8;
    printf("%d",d);
}

 

Answer: A

In the code shown above, the keyword typedef is used to give an alias name (a) to an identifier of the type int. The expression on evaluation gives the answer 10. Hence the output of the code shown above is 10.

Enter details here

74.

What is the output of this C code?

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

 

Answer: B

No answer description available for this question.

Enter details here

75.

What is the output of this C code?

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

 

Answer: A

No answer description available for this question.

Enter details here

76.

What will be the output of the following C code (run without any command line arguments)?

#include 
    int main(int argc, char *argv[])
    {
        while (argv != NULL)
        printf("%s\n",  *(argv++));
        return 0;
    }

 

Answer: A

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