Loading...

C Multiple Choice Questions

Our C questions and answers focuses on all areas of C programming language covering 100+ topics in C

C Arrays and Strings-1 MCQs

C Arrays and Strings-1


1. Which function will you choose to join two words?

a) strcpy()
b) strcat()
c) strncon()
d) memcon()



2. Which among the following is Copying function?

a) memcpy()
b) strcopy()
c) memcopy()
d) strxcpy()



3. The _______ function appends not more than n characters.

a) strcat()
b) strcon()
c) strncat()
d) memcat()



4. What will strcmp() function do?

a) compares the first n characters of the object
b) undefined function
c) copies the string
d) compares the string



5. What is a String in C Language?

a) String is a new Data Type in C
b) String is an array of Characters with null character as the last element of array
c) String is an array of Characters with null character as the first element of array
d) String is an array of Integers with 0 as the last element of array



6. Choose a correct statement about C String.
char ary[] = "Hello......!";

a) Character array, ary is a string
b) ary has no Null character at the end
c) String size is not mentioned
d) String can not contain special characters



7. What is the Format specifier used to print a String or Character array in C Printf or Scanf function?

a) %c
b) %C
c) %s
d) %w



8. What will be the output of the following piece of code?
int main() {
char ary[] = "Discovery Channel";
printf("%s", ary);
return 0;
}

a) D
b) Discovery Channel
c) Discovery
d) Compiler error



9. What is the output of C Program with Strings?
int main() {
char str[] = {'g', 'l', 'o', 'b', 'a', 'l'};
printf("%s", str);
return 0;
}

a) g
b) globe
c) globe\0
d) None of the above



10. What's wrong in the following statement, provided k is a variable of type int?
int main() {
char str[] = {'g', 'l', 'o', 'b', 'a', 'l','\0'};
printf("%s", str);
return 0;
}

a) g
b) globe
c) globe\0
d) Compiler error



- Related Topics