C Language MCQs: C Programming MCQ Part-2

C Language MCQs. Mix C Language Multiple-Choice Questions on Various C topics including Pointers, Values, Initialization, Functions, and Varibles.

 

C Language MCQs

 

The operator used to get value at address stored in a pointer variable is ??

a. *
b. &
c. &&
d. ||

 

A function may have any number of return statements each returning different values ??

a. True
b. False

 

Which of the following statements correctly declare a function that receives a pointer to pointer to a pointer to a float and returns a pointer to a pointer to a pointer to a pointer to a float ??

a. float **fun(float***);
b. float *fun(float**);
c. float fun(float***);
d. float ****fun(float***);

 

Names of functions in two different files linked together must be unique ??

a. True
b. False

 

Are the expression *ptr++ and ++*ptr are same ??

a. True
b. False

 

Functions cannot return a floating-point number ??

a. Yes
b. No

 

Are the three declarations char **apple, char *apple[], and char apple[][] same ?

a. True
b. False

 

Every function must return a value ??

a. Yes
b. No

 

Is there any difference between the following two statements ??
char *p=0;
char *t=NULL;

a. Yes
b. No

 

If a function contains two return statements successively, the compiler will generate warnings. Yes/No ??

a. Yes
b. No

 

C Multiple Choice Questions

 

Is this the correct way for the NULL pointer assignment ??
int i=0;
char *q=(char*)i;

a. Yes
b. No

 

The maximum number of arguments that a function can take is 12 ??

a. Yes
b. No

 

Is the NULL pointer the same as an uninitialized pointer ??

a. Yes
b. No

 

Usually, recursion works slower than loops ??

a. Yes
b. No

 

Which of the following function sets the first n characters of a string to a given character ??

a. strinit()
b. strnset()
c. strset()
d. strcset()

 

Is it true that too many recursive calls may result in stack overflow ??

a. Yes
b. No

 

If the two strings are identical, then strcmp() function returns ??

a. -1
b. 1
c. 0
d. Yes

 

In a function two return statements should never occur ??

a. Yes
b. No

 

How will you print on the screen ??

a. printf(” “);
b. echo “\n”;
c. printf(‘ ‘);
d. printf(“\n”)

 

What is (void*)0 ??

a. Representation of NULL pointer
b. Representation of void pointer
c. Error
d. None of above

 

C Language MCQs

 

The library function used to find the last occurrence of a character in a string is ??

a. strnstr()
b. laststr()
c. strrchr()
d. strstr()

 

Can you combine the following two statements into one ??

a. char p = *malloc(100);
b. char *p = (char) malloc(100);
c. char *p = (char*)malloc(100);
d. char *p = (char *)(malloc*)(100);

 

Which of the following function is used to find the first occurrence of a given string in another string ??

a. strchr()
b. strrchr()
c. strstr()
d. strnset()

 

In which header file is the NULL macro defined ??

a. stdio.h
b. stddef.h
c. stdio.h and stddef.h
d. math.h

 

Which of the following function is more appropriate for reading in a multi-word string ??

a. printf();
b. scanf();
c. gets();
d. puts();

 

Which of the following statements are correct about the below declarations ??
char *p = “myAndroid”;)
char a[] = “myAndroid”;)
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 ” will be added at the end of the string “myAndroid”

a. 1, 2
b. 2, 3, 4
c. 3, 4
d. 2, 3

 

C Language MCQs

 

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 c. strcmp(s1, s2) returns 0 if s1==s2
c. strcmp(s1, s2) returns 1 if s1==s2
d. None of these

 

While calling the print() function in the format string conversion specifier %s can be used to write a character string in capital letters ??

a. True
b. False

 

For the following statements will arr[3] and ptr[3] fetch the same character ??
har arr[] = “myAndroid”;)
char *ptr = “myAndroid”;)

a. Yes
b. No

 

A text stream is an ordered sequence of characters composed of lines, each line consisting of zero or more characters plus a terminating new-line character ??

a. True
b. False

 

Is there any difference between the two statements ??
char *ch = “myAndroid”;)
char ch[] = “myAndroid”;)

a. Yes
b. No

 

The offset used in fseek() function call can be a negative number ??

a. True
b. False

 

C Language MCQs

 

a file contains the line “I am a boy” then on reading this line into the array str using gets(). What will str contain ??

a. “I am a boy “
b. “I am a boy “
c. “I am a boy “
d. “I am a boy”

 

We should not read after a write to a file without an intervening call to fflush(), fseek() or rewind() ??

a. True
b. False

 

To print out a and b were given below, which of the following printf() statements will you use ??
#include
float a=3.14;
double b=3.14;

a. printf(“%f %lf”, a, b);
b. printf(“%Lf %f”, a, b);
c. printf(“%Lf %Lf”, a, b);
d. printf(“%f %Lf”, a, b);

 

In a call to printf() function the format specifier %b can be used to print binary equivalent of an integer ??

a. True
b. False

 

To scan a and b were given below, which of the following scanf() statement will you use ??
#include
float a;
double b;

a. scanf(“%f %f”, &a, &b);
b. scanf(“%Lf %Lf”, &a, &b);
c. scanf(“%f %Lf”, &a, &b);
d. scanf(“%f %lf”, &a, &b);

 

stderr, stdin, stdout are FILE pointers ??

a. Yes
b. No

 

 

Out of fgets() and gets() which function is safe to use ??

a. gets()
b. fgets()

 

C Language MCQs

 

A file written in text mode can be read back in binary mode ??

a. Yes
b. No

 

Can we specify a variable field width in a scanf() format string ??

a. Yes
b. No

 

More C Related Posts

Leave a Comment

Your email address will not be published. Required fields are marked *

error: Content is protected !!