Top

C Constants

71.

What is the output of this C code?

#include 
    #include 
    int main()
    {
        char *str = "x";
        char c = 'x';
        char ary[1];
        ary[0] = c;
        printf("%d %d", strlen(str), strlen(ary));
        return 0;
    }

 

Answer: D

str is null terminated but ary is not.

Output:
$ cc pgm7.c
$ a.out
1 5

Enter details here

72.

The variables which can be accessed by all modules in a program, are called

Answer: D

No answer description available for this question.
 

Enter details here

73.

What is the output of this C code?

#include 
    int main()
    {
        int var = 010;
        printf("%d", var);
    }

 

Answer: B

010 is octal representation of 8.

Output:
$ cc pgm4.c
$ a.out
8

Enter details here

74.

The declaration "unsigned u" indicates u is a/an

Answer: B

No answer description available for this question.

Enter details here

75.

What is the output of this C code?

#include 
    int main()
    {
        printf("C programming %s", "Class by\n%s Sanfoundry", "WOW");
    }

 

Answer: C

This program has only one %s within first double quotes, so it does not read the string “WOW”.
The %s along with the Sanfoundry is not read as a format modifier while new line character prints the new line.
Output:
$ cc pgm2.c
$ a.out
C programming Class by
%s Sanfoundry

Enter details here

76.

We cannot use the way to declare the constant.

Answer: C

No answer description available for this question.
 

Enter details here

77.

What is the output of this C code?

#include 
    #define MAX 2
    enum bird {SPARROW = MAX + 1, PARROT = SPARROW + MAX};
    int main()
    {
        enum bird b = PARROT;
        printf("%d\n", b);
        return 0;
    }

 

Answer: B

MAX value is 2 and hence PARROT will have value 3 + 2.

Output:
$ cc pgm6.c
$ a.out
5

Enter details here

Answer: D

Coercion is automatic conversion between compatible types and it is done by compiler

Enter details here

Answer: C

No answer description available for this question.

Enter details here

80.

The value of ab if ab & 0 x 3f equals 0 x 27 is

Answer: D

Let ab be 0 x MN. N&f should yield 7 i.e. N & 1111 should produce 0111. So, N should be 0111, i.e., 7.Similarly, M can be found to be 2. So, ab is 0 x 27.

Enter details here

Loading…
Tags: C Constants Questions and Answers || C Constants MCQ Questions and Answers || C Constants GK Questions and Answers || C Constants GK MCQ Questions || C Constants Multiple Choice Questions and Answers || C Constants GK || GK on C Constants || C Programming Questions and Answers || C Programming MCQ Questions and Answers || C Programming GK Questions and Answers || GK on C Programming