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.

1.

The difference between x and x is?

A. The first one refers to a variable whose identifier is x and the second one refers to the character constant x
B. The first one is a character constant x and the second one is the string literal x
C. Both are same
D. Both are string literal
Answer» B. The first one is a character constant x and the second one is the string literal x
2.

How to declare a wide character in the string literal?

A. L prefix
B. l prefix
C. W prefix
D. Z prefix
Answer» B. l prefix
3.

Regarding the following statement which of the statements is true? const int a = 100;

A. Declares a variable a with 100 as its initial value
B. Declares a construction a with 100 as its initial value
C. Declares a constant a whose value will be 100
D. Constructs an integer type variable with an as identifier and 100 as the value
Answer» D. Constructs an integer type variable with an as identifier and 100 as the value
4.

Which of the following statement is not true about preprocessor directives?

A. These are lines read and processed by the preprocessor
B. They do not produce any code by themselves
C. These must be written on their own line
D. They end with a semicolon
Answer» E.
5.

What will be the output of the following C++ code? #include using namespace std; int main() { int const p = 5; cout << ++p; return 0; }

A. 5
B. 6
C. Error
D. 8
Answer» D. 8
6.

How are the constants declared?

A. const keyword
B. #define preprocessor
C. both const keyword and #define preprocessor
D. $define
Answer» D. $define
7.

In case of ordinary int variables

A. leftmost bit is reserved for sign
B. rightmost bit is reserved for sign
C. no bit is reserved for sign
D. none of these
Answer» B. rightmost bit is reserved for sign
8.

What is the output of this C code? int main() { enum {ORANGE = 12, MANGO, BANANA = 11, APPLE}; printf("APPLE = %d n", APPLE); }

A. APPLE= 11
B. APPLE= 12
C. APPLE= 23
D. APPLE= 0
Answer» C. APPLE= 23
9.

What is the output of this C code? int main() { printf("C programming %s", "Class by n%s AllIndiaExams", "SUPER"); }

A. C programming Class by SUPER AllIndiaExams
B. C programming Class by n%s AllIndiaExams
C. C programming Class by %s AllIndiaExams
D. Compilation error
Answer» D. Compilation error
10.

For the following code snippet: char *str = AllIndiaExams.in 0? training classes ; The character pointer str holds reference to string:

A. AllIndiaExams.in
B. AllIndiaExams.in training classes
C. AllIndiaExams.in 0training classes
D. Syntax error
Answer» D. Syntax error
11.

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; }

A. 1 1
B. 2 1
C. 2 2
D. 1 (undefined value)
Answer» E.
12.

What is the output of this C code? #include enum birds {SPARROW, PEACOCK, PARROT}; enum animals {TIGER = 8, LION, RABBIT, ZEBRA}; int main() { enum birds m = TIGER; int k; k = m; printf("%d n", k); return 0; }

A. Compile time error
B. 1
C. 8
Answer» E.
13.

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; }

A. Compilation error
B. 5
C. Undefined value
D. 2
Answer» C. Undefined value
14.

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

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

What is the output of the following 'C' program? main { extern int i; i = 20; print("%d",size of (i)); }

A. 2
B. 8
C. Would vary compiler to cimpiler
D. Error
Answer» E.
16.

_______not a primary constant.

A. Integer Constant
B. Real constant
C. Character constant
D. Enum constant
Answer» E.
17.

The C declaration int b [100]; reserves ____________ successive memory locations,each large enough to contain single integer.

A. 200
B. 10,000
C. 100
D. 10
Answer» D. 10
18.

If a is an unsigned integer variable whose value is hx6db7, what is the value of -a?

A. h llhhhhl
B. hxhhl
C. hx248
D. hx9248
Answer» E.
19.

Consider the following statement #define hypotenuse (a, b) sqrt (a*a + b*b); The macro-call hypotenuse (a + 2, b + 3);

A. finds hypotenuse of triangle with sides a + 2 and b+3
B. finds square root of (a + 2)2 + (b + 3)2
C. is meaningless
D. finds square root of 3*a + 4*b + 5
Answer» E.
20.

The rule for implicit type conversion in 'C' is

A. int < unsigned < float < double
B. unsigned < int < float < double
C. int < unsigned>
D. unsigned < int < double < float
Answer» B. unsigned < int < float < double
21.

The declarations typedef float hight [100]; height men, women;

A. define men and women as 100 element floating point arrays
B. define men and women as floating point variables
C. define height, men and women as floating point variables
D. are illegal
Answer» B. define men and women as floating point variables
22.

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

A. local variables
B. internal variables
C. external variable
D. global variables
Answer» E.
23.

A static variable

A. cannot be initialized
B. is initialized once at the commencement of execution and cannot be changed at run time
C. retains its value throughout the file of the program
D. is same as an automatic variable but is placed at the head of a program
Answer» D. is same as an automatic variable but is placed at the head of a program
24.

The statement # include < math.h> is written at the top of a program to indicate

A. beginning of the program
B. beginning of the program
C. that certain information about mathematical library functions are to be included at the begnning of the program
D. none of these
Answer» D. none of these
25.

Constants in C can be divided into categories ?

A. 3
B. 6
C. 2
D. 4
Answer» D. 4
26.

C programming language by itself provides

A. input facility
B. output facility
C. both input and output facilities
D. no input and output facilities
Answer» E.
27.

C programming language provides operations which deal directly with objects such as

A. strings and sets
B. lists and arrays
C. characters, integers, and floating point numbers
D. all of these
Answer» D. all of these
28.

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

A. int
B. float
C. char
D. long int
Answer» C. char
29.

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

A. 047
B. 0 x 0 f
C. 0 x f3
D. 0 x 27
Answer» E.
30.

If the declaration unsigned c:5; is replaced by unsigned : 6; then

A. it results in a syntax error
B. it is meaningless
C. compiler will give a new name for the field
D. none of these
Answer» D. none of these
31.

int i = 5; is a statement in a C program.

A. during execution, value of i may change but not its address
B. during execution both the address and value may change
C. repeated execution may result in different addresses for i
D. i may not have an associated address
Answer» D. i may not have an associated address
32.

Printing a character as an integer

A. results in the printing of a negative integer
B. always prints a positive integer
C. prints a value that is implementation dependent
D. none of these
Answer» D. none of these
33.

The program fragment int i = 263 ; putchar (i) ; prints

A. 263
B. ASCII equivalent of 263
C. rings the bell
D. garbage
Answer» D. garbage
34.

Which of the following 'C' type is not a primitive data structure?

A. int
B. float
C. char
D. none of these
Answer» E.
35.

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

A. unsigned character
B. unsigned integer
C. character
D. none of' these
Answer» C. character
36.

Comment on the output of this C code? int const print() { printf("AllIndiaExams.in"); return 0; } void main() { print(); }

A. AllIndiaExams.in is printed infinite number of times
B. AllIndiaExams.in
C. Runtime Error
D. complilation error
Answer» C. Runtime Error
37.

An external variable

A. is globally accessible by all functions
B. has a declaration
C. will be initialized to 0 if not initialized
D. all of these
Answer» E.
38.

Whats is the output of this C code? void main() { int const k = 11; k++; printf("k is %d", k); }

A. k is 12
B. Error because const and int are used together
C. garbage value
D. Error, because a constant variable cannot be changed
Answer» E.
39.

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

A. a is 32
B. Compile time error
C. Run time error
D. none
Answer» C. Run time error
40.

What is the output of this C code? int main() { printf("AllIndiaExams r nclass n"); return 0; }

A. AllIndiaExamsclass
B. AllIndiaExams class
C. classundry
D. AllIndiaExams
Answer» C. classundry
41.

Consider the statements putchar ( getchar ( )); putchar(getchar( )); if a b is the input, the output will be

A. an error message
B. this can't be the input
C. ab
D. a b
Answer» C. ab
42.

Literal means

A. a string
B. a string constant
C. a character
D. an alphabet
Answer» C. a character
43.

If abc is the input, then the following program fragment char x, y, z ; printf ("% d" , scanf ("%c%c%c" , &x , &y , &z )) ; results in

A. a syntax error
B. a fatal error
C. segmentation violation
D. printing of 3
Answer» E.
44.

printf ( "%d" , printf ( "tim" ) ):

A. results in a syntax error
B. outputs tim3
C. outputs garbage
D. prints tim and terminates abruptly
Answer» C. outputs garbage
45.

If s and b are integers then purpose of the following program fragment is to b = s + b ; s = b - s ; b = b - s ;

A. transfer the contents of s to b
B. transfer the content of b to s
C. exchange (swap) the contents of s and b
D. negate the contents of s and b
Answer» D. negate the contents of s and b
46.

Which of the following comments regarding the reading of a string, using scanf(with optional) and get is true?

A. Both can be used interchangeably
B. Scanf is delimited by end of line, while gets is not
C. Scanf is delimited by blank, while gets is not
D. All of above
Answer» D. All of above
47.

Choose the correct answer

A. Enum variables can not be assigned new values
B. Enum variables can be compared
C. Enumeration feature increase the power of C
D. All of above
Answer» D. All of above
48.

The minimum number of temporary variables needed to swap the contents of two variables is

A. 1
B. 2
C. 3
Answer» A. 1
49.

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

A. Undefined
B. 20
C. Error
D. Garbage Value
Answer» C. Error
50.

enum types are processed by?

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