Explore topic-wise MCQs in C Constants.

This section includes 81 Mcqs, each offering curated multiple-choice questions to sharpen your C Constants knowledge and support exam preparation. Choose a topic below to get started.

51.

What is the output of this C code? int main() { int var = 010; printf("%d", var); }

A. 2
B. 8
C. 9
D. 10
Answer» C. 9
52.

The library function sqrt operates on a double precision argument. If, i is an integer variable, then which of the following calls would correctly compute sqrt(i)?

A. sqrt((double)i)
B. (double)sqrt(i)?
C. (double)(sqrt(i))
D. sqrt(i)
Answer» B. (double)sqrt(i)?
53.

When a variable of data type double is converted into float, then

A. Rounding takes place
B. Truncation takes place
C. The lower order bits are dropped
D. None of these
Answer» B. Truncation takes place
54.

By default, any real number in 'C' is treated as

A. A float
B. A double
C. A long double
D. Depend upon memory model that you are using
Answer» C. A long double
55.

To print out a and b given below, which printf() statement would you use? float a = 3.14; double b = 3.14;

A. printf("%f%f",a,b);
B. printf("%Lf%f",a,b);
C. printf("%Lf%Lf",a,b);
D. printf("%f%Lf",a,b);
Answer» B. printf("%Lf%f",a,b);
56.

The rule for implicit type conversion is

A. int < unsigned < float < double
B. unsigned < int < float < double
C. int < unsigned < double < float
D. unsigned < inc < double < float
Answer» B. unsigned < int < float < double
57.

What is the correct way to round offx, a float, to an int value?

A. y=(int)(x+0.5)
B. y=int(x+0.5)
C. y=(int)x+0.5
D. y=(int)(int)x+0.5)
Answer» B. y=int(x+0.5)
58.

As soon as a pointer variable is freed, its value

A. is set to null
B. becomes unpredictable
C. is set to 1
D. remains the same
Answer» E.
59.

In a C program constant is defined

A. before main
B. after main
C. anywhere, but starting on a new line
D. none of the above
Answer» D. none of the above
60.

The declaration int x : 4; means

A. x is a four digit integer
B. x cannot be greater than a four digit integer
C. x is a four-bit integer
D. none of above
Answer» D. none of above
61.

Which of the following comments about wide characters is/are true ?

A. it is binary representation of a character in the extended binary set
B. it is of integer type wchar_t
C. end of file is represented by WEOF
D. All of the above
Answer» E.
62.

Which of the following is true of external variables?

A. they provide a way for two way communication between functions
B. their scope extends from the point of definition through the remainder of the program
C. if they are not initialized, they will be initilised to zero
D. All of the above
Answer» E.
63.

The value of an automatic variable that is declared but not initialized will be

A. -1
B. unpredictable
C. none of these
Answer» D.
64.

Which of the following are true regardless of the implementation ?

A. sizeof(int) is not less than sizeof(long)
B. sizeof(double) is not less than sizeof(float)
C. sizeof (int )equals sizeof(unsigned)
D. both (b) & (c)
Answer» E.
65.

If a variable can take only integral values from 0 to n. where n is a constant integer, then the variable can be represented as a bit-field whose width is the integral part of (the log in the answers arc to the base 2)

A. log (n) + 1
B. log (n - 1) + 1
C. log (n + 1) + 1
D. none of the above
Answer» B. log (n - 1) + 1
66.

What is the output of this C code? #define a 20 int main() { const int a = 50; printf("a = %d n", a); }

A. a = 50
B. a = 20
C. Run time error
D. Compilation Error
Answer» E.
67.

Choose the correct statements

A. enum is a data type.
B. enum feature is an alternative to the define feature
C. In the same enumeration values must be distinct
D. Both (a) and (b)
Answer» E.
68.

A declaration "short int" is used for variables

A. which have a short duration in a program
B. which have short names
C. which may require less storage than normal integers
D. all of these
Answer» D. all of these
69.

Comment on the output of this C code? #include void main() { int const k = 5; k++; printf("k is %d", k); }

A. k is 6
B. Error due to const succeeding int
C. Error, because a constant variable can be changed only twice
D. Error, because a constant variable cannot be changed
Answer» E.
70.

Which is false?

A. Constant variables need not be defined as they are declared and can be defined later
B. Global constant variables are initialised to zero
C. const keyword is used to define constant values
D. You cannot reassign a value to a constant variable
Answer» B. Global constant variables are initialised to zero
71.

Comment on the output of this C code? #include void main() { int k = 4; int *const p = &k; int r = 3; p = &r; printf("%d", p); }

A. Address of k
B. Address of r
C. Compile time error
D. Adress of k + address of r
Answer» D. Adress of k + address of r
72.

What is the output of this C code? #include int main() { const int p; p = 4; printf("p is %d", p); return 0; }

A. p is 4
B. Compile time error
C. Run time error
D. p is followed by a garbage value
Answer» C. Run time error
73.

enum types are processed by

A. Compiler
B. Preprocessor
C. Linker
D. Assembler
Answer» B. Preprocessor
74.

What is the output of this C code? #include #define a 10 int main() { const int a = 5; printf("a = %d n", a); }

A. a = 5
B. a = 10
C. Compilation error
D. Runtime error
Answer» D. Runtime error
75.

What is the output of this C code? #include int main() { enum {ORANGE = 5, MANGO, BANANA = 4, PEACH}; printf("PEACH = %d n", PEACH); }

A. PEACH = 3
B. PEACH = 4
C. PEACH = 5
D. PEACH = 6
Answer» D. PEACH = 6
76.

The declaration enum cities{ bethlehem, jericho, nazareth = 1, jerusalem } assigns the value 1 to

A. bethlehem
B. nazareth
C. bethIehem and nazareth
D. jericho and nazareth
Answer» E.
77.

The statement printf( " % f ", ( float )9/5) ; prints

A. 1.8
B. 1.0
C. 2.0
D. none of these
Answer» B. 1.0
78.

What are the parts of the literal constants?

A. integer numerals
B. floating-point numerals
C. strings and boolean values
D. all of the mentioned
Answer» E.
79.

The constants are also called as _____________

A. const
B. preprocessor
C. literals
D. variables
Answer» D. variables
80.

------not a secondry constant.

A. Character
B. Array
C. Pointer Structure
D. Union
Answer» B. Array
81.

We cannot use the way to declare the constant.

A. const int a = 1;
B. int const a = 1;
C. int constant a=1
D. none
Answer» D. none