Top

C Constants

31.

What is the output of this C code?

#include 
    int main()
    {
        const int p;
        p = 4;
        printf("p is %d", p);
        return 0;
    }

 

Answer: B

Since the constant variable has to be declared and defined at the same time, not doing it results in an error.

Output:
$ cc pgm10.c
pgm10.c: In function ‘main’:
pgm10.c:5: error: assignment of read-only variable ‘p’

Enter details here

32.

In C programming language, if the first and the second operands of operator + are of types int and float, respectively, the result will be of type

Answer: B

No answer description available for this question.
 

Enter details here

33.

What is the output of the following 'C' program?
main()
{
extern int a;
printf("\n%d",a);
}
int a=20;

Answer: B

No answer description available for this question.
 

Enter details here

Answer: D

No answer description available for this question.
 

Enter details here

Answer: D

No answer description available for this question.
 

Enter details here

36.

What is the output of this C code?

int main()
{
enum {ORANGE = 12, MANGO, BANANA = 11, APPLE};
printf("APPLE = %d\n", APPLE);
}

 

Answer: B

In enum, the value of constant is defined to the recent assignment from left.

Enter details here

Answer: C

Because the const is used to declare non-changeable values only.

Enter details here

38.

Comment on the output of this C code?

#include 
    int const print()
    {
        printf("Sanfoundry.com");
        return 0;
    }
    void main()
    {
        print();
    }

 

Answer: B

None.

Output:
$ cc pgm13.c
$ a.out

Enter details here

Answer: D

No terminating character required for preprocessor directives statements

Enter details here

Answer: D

No answer description available for this question.
 

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