MCQOPTIONS
Saved Bookmarks
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.
| 101. |
What does the following function returns void *memmove(void *s1,const void s2, size_t n);? |
| A. | returns the value of s1 |
| B. | returns the value of s2 |
| C. | doesn't return any value |
| D. | returns the value of s1 and s2 |
| Answer» B. returns the value of s2 | |
| 102. |
Which among the given options is the right explanation for the statement size_t strcspn(c, s)? |
| A. | return length of prefix of s consisting of characters not in c |
| B. | return length of prefix of s consisting of characters present in c |
| C. | return length of prefix of c consisting of characters not in s |
| D. | return length of prefix of c consisting of characters present in s |
| Answer» D. return length of prefix of c consisting of characters present in s | |
| 103. |
What is the function of void *memset(s, c, n)? |
| A. | places character s into first n characters of c, return c |
| B. | places character c into first n characters of s, return s |
| C. | places character s into first n characters of c, return s |
| D. | places character c into first n character of s, return c |
| Answer» C. places character s into first n characters of c, return s | |
| 104. |
What is the use of function char *strchr(ch, c)? |
| A. | return pointer to first occurrence of ch in c or NULL if not present |
| B. | return pointer to first occurrence of c in ch or NULL if not present |
| C. | return pointer to first occurrence of ch in c or ignores if not present |
| D. | return pointer to first occurrence of cin ch or ignores if not present |
| Answer» C. return pointer to first occurrence of ch in c or ignores if not present | |
| 105. |
Functions whose names begin with “strn” |
| A. | manipulates sequences of arbitrary characters |
| B. | manipulates null-terminated sequences of characters |
| C. | manipulates sequence of non – null characters. |
| D. | returns a pointer to the token |
| Answer» D. returns a pointer to the token | |
| 106. |
What will be the output of the program ? #include int main() { char str1[] = "Hello"; char str2[10]; char *t, *s; s = str1; t = str2; while(*t=*s) *t++ = *s++; printf("%s\n", str2); return 0; } |
| A. | Hello |
| B. | HelloHello |
| C. | No output |
| D. | ello |
| Answer» B. HelloHello | |
| 107. |
What will be the output of the program ? #include int main() { printf(5+"IndiaBIX\n"); return 0; } |
| A. | Error |
| B. | IndiaBIX |
| C. | BIX |
| D. | None of above |
| Answer» D. None of above | |
| 108. |
What will be the output of the program ? #include #include int main() { char str1[5], str2[5]; int i; gets(str1); gets(str2); i = strcmp(str1, str2); printf("%d\n", i); return 0; } |
| A. | Unpredictable integer value |
| B. | 0 |
| C. | -1 |
| D. | Error |
| Answer» B. 0 | |
| 109. |
What will be the output of the program ? #include int main() { char *names[] = { "Suresh", "Siva", "Sona", "Baiju", "Ritu"}; int i; char *t; t = names[3]; names[3] = names[4]; names[4] = t; for(i=0; i |
| A. | Suresh, Siva, Sona, Baiju, Ritu |
| B. | Suresh, Siva, Sona, Ritu, Baiju |
| C. | Suresh, Siva, Baiju, Sona, Ritu |
| D. | Suresh, Siva, Ritu, Sona, Baiju |
| Answer» C. Suresh, Siva, Baiju, Sona, Ritu | |
| 110. |
What will be the output of the program ? #include #include int main() { printf("%c\n", "abcdefgh"[4]); return 0; } |
| A. | Error |
| B. | d |
| C. | e |
| D. | abcdefgh |
| Answer» D. abcdefgh | |
| 111. |
What will be the output of the program in 16-bit platform (Turbo C under DOS) ? #include int main() { printf("%d, %d, %d", sizeof(3.0f), sizeof('3'), sizeof(3.0)); return 0; } |
| A. | 8, 1, 4 |
| B. | 4, 2, 8 |
| C. | 4, 2, 4 |
| D. | 10, 3, 4 |
| Answer» C. 4, 2, 4 | |
| 112. |
If the size of pointer is 4 bytes then What will be the output of the program ? #include int main() { char *str[] = {"Frogs", "Do", "Not", "Die", "They", "Croak!"}; printf("%d, %d", sizeof(str), strlen(str[0])); return 0; } |
| A. | 22, 4 |
| B. | 25, 5 |
| C. | 24, 5 |
| D. | 20, 2 |
| Answer» D. 20, 2 | |
| 113. |
What will be the output of the program ? #include #include int main() { char sentence[80]; int i; printf("Enter a line of text\n"); gets(sentence); for(i=strlen(sentence)-1; i >=0; i--) putchar(sentence[i]); return 0; } |
| A. | The sentence will get printed in same order as it entered |
| B. | The sentence will get printed in reverse order |
| C. | Half of the sentence will get printed |
| D. | None of above |
| Answer» C. Half of the sentence will get printed | |
| 114. |
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) ? #include int main() { printf("%u %s\n", &"Hello1", &"Hello2"); return 0; } |
| A. | 1022 Hello2 |
| B. | Hello1 1022 |
| C. | Hello1 Hello2 |
| D. | 1022 1022 |
| Answer» B. Hello1 1022 | |
| 115. |
What will be the output of the program ? #include int main() { static char mess[6][30] = {"Don't walk in front of me...", "I may not follow;", "Don't walk behind me...", "Just walk beside me...", "And be my friend." }; printf("%c, %c\n", *(mess[2]+9), *(*(mess+2)+9)); return 0; } |
| A. | t, t |
| B. | k, k |
| C. | n, k |
| D. | m, f |
| Answer» C. n, k | |
| 116. |
What will be the output of the program ? #include int main() { int i; char a[] = "\0"; if(printf("%s", a)) printf("The string is empty\n"); else printf("The string is not empty\n"); return 0; } |
| A. | The string is empty |
| B. | The string is not empty |
| C. | No output |
| D. | 0 |
| Answer» C. No output | |
| 117. |
What will be the output of the program ? #include int main() { char str[] = "Nagpur"; str[0]='K'; printf("%s, ", str); str = "Kanpur"; printf("%s", str+1); return 0; } |
| A. | Kagpur, Kanpur |
| B. | Nagpur, Kanpur |
| C. | Kagpur, anpur |
| D. | Error |
| Answer» E. | |
| 118. |
What will be the output of the program (Turbo C in 16 bit platform DOS) ? #include #include int main() { char *str1 = "India"; char *str2 = "BIX"; char *str3; str3 = strcat(str1, str2); printf("%s %s\n", str3, str1); return 0; } |
| A. | IndiaBIX India |
| B. | IndiaBIX IndiaBIX |
| C. | India India |
| D. | Error |
| Answer» C. India India | |
| 119. |
What will be the output of the program ? #include #include int main() { char str[] = "India\0\BIX\0"; printf("%d\n", strlen(str)); return 0; } |
| A. | 10 |
| B. | 6 |
| C. | 5 |
| D. | 11 |
| Answer» D. 11 | |
| 120. |
What will be the output of the program ? #include int main() { char t; char *p1 = "India", *p2; p2=p1; p1 = "BIX"; printf("%s %s\n", p1, p2); return 0; } |
| A. | India BIX |
| B. | BIX India |
| C. | India India |
| D. | BIX BIX |
| Answer» C. India India | |
| 121. |
What will be the output of the program ? #include int main() { static char s[25] = "The cocaine man"; int i=0; char ch; ch = s[++i]; printf("%c", ch); ch = s[i++]; printf("%c", ch); ch = i++[s]; printf("%c", ch); ch = ++i[s]; printf("%c", ch); return 0; } |
| A. | hhe! |
| B. | he c |
| C. | The c |
| D. | Hhec |
| Answer» B. he c | |
| 122. |
What will be the output of the program ? #include int main() { printf("India", "BIX\n"); return 0; } |
| A. | Error |
| B. | India BIX |
| C. | India |
| D. | BIX |
| Answer» D. BIX | |
| 123. |
What will be the output of the program ? #include int main() { int i; char a[] = "\0"; if(printf("%s", a)) printf("The string is not empty\n"); else printf("The string is empty\n"); return 0; } |
| A. | The string is not empty |
| B. | The string is empty |
| C. | No output |
| D. | 0 |
| Answer» C. No output | |
| 124. |
If the size of pointer is 32 bits What will be the output of the program ? #include int main() { char a[] = "Visual C++"; char *b = "Visual C++"; printf("%d, %d\n", sizeof(a), sizeof(b)); printf("%d, %d", sizeof(*a), sizeof(*b)); return 0; } |
| A. | 10, 22, 2 |
| B. | 10, 41, 2 |
| C. | 11, 41, 1 |
| D. | 12, 22, 2 |
| Answer» D. 12, 22, 2 | |
| 125. |
What will be the output of the program ? #include #include int main() { static char s[] = "Hello!"; printf("%d\n", *(s+strlen(s))); return 0; } |
| A. | 8 |
| B. | 0 |
| C. | 16 |
| D. | Error |
| Answer» C. 16 | |
| 126. |
What will be the output of the program ? #include int main() { char str[] = "India\0BIX\0"; printf("%d\n", sizeof(str)); return 0; } |
| A. | 10 |
| B. | 6 |
| C. | 5 |
| D. | 11 |
| Answer» E. | |
| 127. |
What will be the output of the program ? #include int main() { char str1[] = "Hello"; char str2[] = "Hello"; if(str1 == str2) printf("Equal\n"); else printf("Unequal\n"); return 0; } |
| A. | Equal |
| B. | Unequal |
| C. | Error |
| D. | None of above |
| Answer» C. Error | |
| 128. |
What will be the output of the program ? #include int main() { char str[7] = "IndiaBIX"; printf("%s\n", str); return 0; } |
| A. | Error |
| B. | IndiaBIX |
| C. | Cannot predict |
| D. | None of above |
| Answer» D. None of above | |
| 129. |
What will be the output of the program ? #include int main() { char str = "IndiaBIX"; printf("%s\n", str); return 0; } |
| A. | Error |
| B. | IndiaBIX |
| C. | Base address of str |
| D. | No output |
| Answer» B. IndiaBIX | |
| 130. |
What will be the output of the program ? #include int main() { char str[25] = "IndiaBIX"; printf("%s\n", &str+2); return 0; } |
| A. | Garbage value |
| B. | Error |
| C. | No output |
| D. | diaBIX |
| Answer» B. Error | |
| 131. |
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 | |
| 132. |
What will be the output of the program ? #include int main() { printf(5+"Good Morning\n"); return 0; } |
| A. | Good Morning |
| B. | Good |
| C. | M |
| D. | Morning |
| Answer» E. | |
| 133. |
Which of the following function is correct that finds the length of a string? |
| A. | int xstrlen(char *s) { int length=0; while(*s!='\0') { length++; s++; } return (length); } |
| B. | int xstrlen(char s) { int length=0; while(*s!='\0') length++; s++; return (length); } |
| C. | int xstrlen(char *s) { int length=0; while(*s!='\0') length++; return (length); } |
| D. | int xstrlen(char *s) { int length=0; while(*s!='\0') s++; return (length); } |
| Answer» B. int xstrlen(char s) { int length=0; while(*s!='\0') length++; s++; return (length); } | |
| 134. |
What will be the output of the program ? #include #include int main() { char str[] = "India\0\BIX\0"; printf("%s\n", str); return 0; } |
| A. | BIX |
| B. | India |
| C. | India BIX |
| D. | India\0BIX |
| Answer» C. India BIX | |
| 135. |
Is there any difference between the two statements? char *ch = "IndiaBIX";char ch[] = "IndiaBIX"; |
| A. | Yes |
| B. | No |
| Answer» B. No | |
| 136. |
If char=1, int=4, and float=4 bytes size, What will be the output of the program ? #include int main() { char ch = 'A'; printf("%d, %d, %d", sizeof(ch), sizeof('A'), sizeof(3.14f)); return 0; } |
| A. | 1, 2, 4 |
| B. | 1, 4, 4 |
| C. | 2, 2, 4 |
| D. | 2, 4, 8 |
| Answer» C. 2, 2, 4 | |
| 137. |
What will be the output of the program ? #include int main() { char p[] = "%d\n"; p[1] = 'c'; printf(p, 65); return 0; } |
| A. | A |
| B. | a |
| C. | c |
| D. | 65 |
| Answer» B. a | |
| 138. |
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 | |
| 139. |
What will be the output of the program ? #include #include int main() { printf("%d\n", strlen("123456")); return 0; } |
| A. | 6 |
| B. | 12 |
| C. | 7 |
| D. | 2 |
| Answer» B. 12 | |
| 140. |
For the following statements will arr[3] and ptr[3] fetch the same character? char arr[] = "IndiaBIX";char *ptr = "IndiaBIX"; |
| A. | Yes |
| B. | No |
| Answer» B. No | |
| 141. |
What will be the output of the program ? #include #include int main() { static char str1[] = "dills"; static char str2[20]; static char str3[] = "Daffo"; int i; i = strcmp(strcat(str3, strcpy(str2, str1)), "Daffodills"); printf("%d\n", i); return 0; } |
| A. | 0 |
| B. | 1 |
| C. | 2 |
| D. | 4 |
| Answer» B. 1 | |
| 142. |
What will be the output of the program in Turbo C? #include int main() { char str[10] = "India"; str[6] = "BIX"; printf("%s\n", str); return 0; } |
| A. | India BIX |
| B. | BIX |
| C. | India |
| D. | Error |
| Answer» E. | |
| 143. |
What will be the output of the program If characters 'a', 'b' and 'c' enter are supplied as input? #include int main() { void fun(); fun(); printf("\n"); return 0; } void fun() { char c; if((c = getchar())!= '\n') fun(); printf("%c", c); } |
| A. | abc abc |
| B. | bca |
| C. | Infinite loop |
| D. | cba |
| Answer» E. | |
| 144. |
What will be the output of the program ? #include void swap(char *, char *); int main() { char *pstr[2] = {"Hello", "IndiaBIX"}; swap(pstr[0], pstr[1]); printf("%s\n%s", pstr[0], pstr[1]); return 0; } void swap(char *t1, char *t2) { char *t; t=t1; t1=t2; t2=t; } |
| A. | IndiaBIXHello |
| B. | Address of "Hello" and "IndiaBIX" |
| C. | HelloIndiaBIX |
| D. | IelloHndiaBIX |
| Answer» D. IelloHndiaBIX | |
| 145. |
Which of the following statements are correct about the program below? #include int main() { char str[20], *s; printf("Enter a string\n"); scanf("%s", str); s=str; while(*s != '\0') { if(*s >= 97 && *s |
| 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 | |
| 146. |
Will the program compile successfully? #include int main() { char a[] = "India"; char *p = "BIX"; a = "BIX"; p = "India"; printf("%s %s\n", a, p); return 0; } |
| A. | Yes |
| B. | No |
| C. | Yes |
| D. | No |
| Answer» C. Yes | |
| 147. |
Which of the following function is more appropriate for reading in a multi-word string? |
| A. | printf(); |
| B. | scanf(); |
| C. | gets(); |
| D. | puts(); |
| Answer» D. puts(); | |
| 148. |
How will you print \n on the screen? |
| A. | printf("\n"); |
| B. | echo "\\n"; |
| C. | printf('\n'); |
| D. | printf("\\n"); |
| Answer» E. | |
| 149. |
If the two strings are identical, then strcmp() function returns |
| A. | -1 |
| B. | 1 |
| C. | 0 |
| D. | Yes |
| Answer» D. Yes | |
| 150. |
What will be the output of the program ? #include #include int main() { char str1[20] = "Hello", str2[20] = " World"; printf("%s\n", strcpy(str2, strcat(str1, str2))); return 0; } |
| A. | Hello |
| B. | World |
| C. | Hello World |
| D. | WorldHello |
| Answer» D. WorldHello | |