Explore topic-wise MCQs in C Programming.

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

51.

What could be output of the following fragment of code?public class Test{public static void main(String args[]){String x = "hellow";int y = 9;System.out.println(x += y);}}

A. hrows an exception as string and int are not compatible for addition
B. ellow9
C. hellow
D. ompilation error
E. one of these
Answer» C. hellow
52.

Determine output:public class Test{public static void main(String args[]){String s1 = "SITHA";String s2 = "RAMA";System.out.println(s1.charAt(0) > s2.charAt(0));}}

A. rue
B. alse
C.
D. ompilation error
Answer» B. alse
53.

What will be the output of the following program?public class Test{public static void main(String args[]){String s1 = "java";String s2 = "java";System.out.println(s1.equals(s2));System.out.println(s1 == s2);}}

A. alse true
B. alse false
C. rue false
D. rue true
Answer» E.
54.

What will be the output of the following program code?class LogicalCompare{public static void main(String args[]){String str1 = new String("OKAY");String str2 = new String(str1);System.out.println(str1 == str2);}}

A. rue
B. alse
C.
Answer» C.
55.

The output of the following fraction of code ispublic class Test{public static void main(String args[]){String s1 = new String("Hello");String s2 = new String("Hellow");System.out.println(s1 = s2); }}

A. ello
B. ellow
C. ompilation error
D. hrows an exception
E. one of these
Answer» C. ompilation error
56.

Which of the following statements are correct about the below declarations?char *p = "Sanjay";char a[] = "Sanjay";1: There is no difference in the declarations and both serve the same purpose.2: p is a non-const pointer pointing to a non-const string, whereas a is a const pointer pointing to a non-const pointer.3: The pointer p can be modified to point to another string, whereas the individual characters within array a can be changed.4: In both cases the '\0' will be added at the end of the string "Sanjay".

A. 1, 2
B. 2, 3, 4
C. 3, 4
D. 2, 3
Answer» C. 3, 4
57.

Arithmetic operations are not allowed on enumerated constants.

A. True
B. False
C. May be True or False
D. Can't Say
Answer» C. May be True or False
58.

Which of the following statement is correct?

A. strcmp(s1, s2) returns a number less than 0 if s1>s2
B. strcmp(s1, s2) returns a number greater than 0 if s1<s2
C. strcmp(s1, s2) returns 0 if s1==s2
D. strcmp(s1, s2) returns 1 if s1==s2
Answer» D. strcmp(s1, s2) returns 1 if s1==s2
59.

What is the correct syntax of enum?

A. enum flag{constant1, constant2, constant3, ....... };
B. enum flag(constant1, constant2, constant3, ....... );
C. enum flag[constant1, constant2, constant3, ....... ];
D. enumflag{constant1, constant2, constant3, ....... };
Answer» B. enum flag(constant1, constant2, constant3, ....... );
60.

If we do not explicitly assign values to enum names, the compiler by default assigns values to ?

A.
B. -1
C. 0
D. Garbage
Answer» D. Garbage
61.

All enum constants are

A. Same in their scope
B. unique in their scope
C. contain dupicate value in their scope
D. None of the above
Answer» C. contain dupicate value in their scope
62.

Enumeration (or enum) is a ______ data type in C.

A. user defined
B. built-in
C. libary
D. None Of the above
Answer» B. built-in
63.

What will be the output of the following program in 16 bit platform assuming that 1022 is memory address of the string "Hello1" (in Turbo C under DOS) ?

A. 1022 Hello2
B. Hello1 1022
C. Hello1 Hello2
D. 1022 1022
Answer» B. Hello1 1022
64.

Which of the following statements are correct about the below declarations?char *p = "Sanjay";char a[] = "Sanjay";1: There is no difference in the declarations and both serve the same purpose.2: p is a non-const pointer pointing to a non-const string, whereas a is a const pointer pointing to a non-const pointer.3: The pointer p can be modified to point to another string, whereas the individual characters within array a can be changed.4: In both cases the '\0' will be added at the end of the string "Sanjay".

A. 1, 2
B. 2, 3, 4
C. 3, 4
D. 2, 3
Answer» C. 3, 4
65.

Which of the following statements are correct about the program below?

A. The code converts a string in to an integer
B. The code converts lower case character to upper case
C. The code converts upper case character to lower case
D. Error in code
Answer» C. The code converts upper case character to lower case
66.

Which of the following statements are correct ?1: A string is a collection of characters terminated by '\0'.2: The format specifier %s is used to print a string.3: The length of the string can be obtained by strlen().4: The pointer CANNOT work on string.

A. 1, 2
B. 1, 2, 3
C. 2, 4
D. 3, 4
Answer» C. 2, 4
67.

Length of the string "compsciedu" is

A. 11
B. 10
C. 9
D. 12
Answer» C. 9
68.

How will you print ' ' on the screen?

A. printf("
B. printf('
C. printf("\n");
D. printf(""
Answer» D. printf(""
69.

Which of the following statements are correct ?

A. 1,2,3
B. 1,2
C. 2,4
D. 3,4
Answer» B. 1,2
70.

Let x be an array.Which of the following operations is illegal?

A. I and II
B. I, III and IV
C. III and IV
D. II and III
Answer» E.
71.

If the size of pointer is 4 bytes then What will be the output of the program ?

A. 22, 4
B. 25, 5
C. 24, 5
D. 20, 2
Answer» D. 20, 2
72.

What will be the output of the program (Turbo C in 16 bit platform DOS) ?

A. CompSciBits CompSci
B. CompSciBits CompSciBits
C. CompSci CompSci
D. Error
Answer» C. CompSci CompSci
73.

What will be the output of the program in Turbo C?

A. CompSci Bits
B. Bits
C. CompSci
D. Error
Answer» E.
74.

What will be the output of the program in 16-bit platform (Turbo C under DOS) ?

A. 8, 1, 4
B. 4, 2, 8
C. 4, 2, 4
D. 10, 3, 4
Answer» C. 4, 2, 4
75.

If char=1, int=4, and float=4 bytes size, What will be the output of the program ?

A. 1, 2, 4
B. 1, 4, 4
C. 2, 2, 4
D. 2, 4, 8
Answer» C. 2, 2, 4
76.

If the size of pointer is 32 bits What will be the output of the program ?

A. 10, 22, 2
B. 10, 41, 2
C. 11, 41, 1
D. 12, 22, 2
Answer» D. 12, 22, 2
77.

What is the output of the given code ?

A. Empty String
B. String is not empty
C. 0
D. None of the above
Answer» C. 0
78.

How many times the loop will execute ?

A. 98
B. 0
C. 98766
D. 90765
Answer» E.
79.

Which of the following gives the memory address of the first element in array foo, an array with 10 elements?

A. foo
B. &foo;
C. foo[0]
D. &foo;[0]
Answer» B. &foo;
80.

What will be the output of the program If characters 'a', 'b' and 'c' enter are supplied as input?

A. abc abc
B. bca
C. Infinite loop
D. cba
Answer» E.
81.

No library function will store a zero in errno.

A. true
B. false
Answer» B. false
82.

There are two groups of string functions defined in the header . What are they?

A. first group names beginning with str; second group names beginning with mem
B. first group names beginning with str; second group names beginning with is
C. first group names beginning with string; second group names beginning with mem
D. first group names beginning with str; second group names beginning with type
Answer» B. first group names beginning with str; second group names beginning with is
83.

__________ tells the compiler that this data is defined somewhere and will be connected with the linker.

A. errno
B. extern
C. variable
D. yvals
Answer» C. variable
84.

errno causes trouble in two subtler ways(vague and explicit).

A. true
B. false
Answer» B. false
85.

Which of the following is the right syntax to copy n characters from the object pointed to by s2 into the object pointed to by s1?

A. void *memcpy(void *s1,const void *s2,size_t n);
B. void *memcpy(void *s2, const void *s1, size_t n);
C. void memcpy(void *s1,const void *s2, size_t n);
D. void memcpy(void *s2,const void *s1,size_t n);
Answer» B. void *memcpy(void *s2, const void *s1, size_t n);
86.

The mem functions are meant for _______

A. returning a pointer to the token
B. manipulating objects as character arrays
C. returning a pointer for implemented-defined string
D. returning a pointer to first occurrence of string in another string
Answer» C. returning a pointer for implemented-defined string
87.

Which among the following option is the full set of character class Hexadecimal digits?

A. { 0 1 2 3 4 5 6 7 8 9 A B C D E F }
B. { 0 1 2 3 4 5 6 7 8 9 a b c d e f }
C. { 0 1 2 3 4 5 6 7 8 9 A B C D E F a b c d e f }
D. { 0 1 2 3 4 5 6 7 8 9}
Answer» D. { 0 1 2 3 4 5 6 7 8 9}
88.

_______ occurs when a result is too large in magnitude to represent errors as a floating-point value of the required type.

A. underflow
B. significance loss
C. domain
D. overflow
Answer» E.
89.

What occurs when a result has nowhere near the number of significant digits indicated by its type.

A. domain
B. underflow
C. overflow
D. significance loss
Answer» E.
90.

Which header declares several functions useful for testing and mapping characters?

A. assert.h
B. stdio.h
C. ctype.h
D. errno.h
Answer» D. errno.h
91.

Which among the given options compares atmost n characters of string ch to string s?

A. int strncmp(ch, s, n)
B. int strcmp(ch, s)
C. int strncmp(s, ch, n)
D. int strcmp(s, ch)
Answer» B. int strcmp(ch, s)
92.

Which code from the given option return pointer to last occurrence of c in ch or NULL if not present?

A. char *strchr(ch, c)
B. char *strrchr(ch,
C. char *strncat(ch, c)
D. char *strcat(ch, c)
Answer» C. char *strncat(ch, c)
93.

The______ function returns the number of characters that are present before the terminating null character.

A. strlength()
B. strlen()
C. strlent()
D. strchr()
Answer» C. strlent()
94.

Which among the following is Copying function?

A. memcpy()
B. strcopy()
C. memcopy()
D. strxcpy()
Answer» B. strcopy()
95.

How will you print n on the screen?

A. printf(''\n'');
B. echo ''\\n'';
C. printf('\n');
D. printf(''\\n'');
Answer» E.
96.

What is the return value of strxfrm()?

A. length of the transformed string, not including the terminating null-character
B. length of the transformed string, including the terminating null-character
C. display the transformed string, not including the terminating null character
D. display the transformed string, not including the terminating null-character
Answer» B. length of the transformed string, including the terminating null-character
97.

Use_______to determine the null-terminated message string that corresponds to the error code errcode.

A. strerror()
B. strstr()
C. strxfrm()
D. memset()
Answer» B. strstr()
98.

What error occurs when a result is undefined for a given argument value?

A. significance loss
B. underflow
C. overflow
D. domain
Answer» E.
99.

The isdigit function tests for any decimal-digit character.

A. true
B. FALSE
Answer» C.
100.

void *memcpy(void *dest, const void *src, size_t n) What does the following code do?

A. copies n characters from src to dest
B. copies n character from dest to src
C. transform n character from dest to src
D. transform n character from src to dest
Answer» B. copies n character from dest to src