C Programming Quiz

Quiz on String Manipulation in C

Time left: 300 seconds

Q.1. Which among the following is Copying function?

Select Your Option

The memcpy() function is used to copy n characters from the object. The code is void *memcpy(void *s1,const void *s2, size_t n).

Q.2. Which function will you choose to join two words?

Select Your Option

The strcat() function is used for concatenating two strings, appends a copy of the string. char *strcat(char *s1,const char *s2);

Q.3. The ______ function appends not more than n characters.

Select Your Option

The strncat() function appends not more than n characters from the array(s2) to the end of the string(s1).char *strncat(char *s1, const char *s2,size_t n);

Q.4. What does strcmp() function do?

Select Your Option

The strcmp() function compares the string s1 to the string s2. int strcmp(const char *s1,const char *s2);

Q.5. What is the prototype of strcoll() function?

Select Your Option

The prototype of strcoll() function is int strcoll(const char *s1,const char *s2).

Q.6. What is the function of strcoll()?

Select Your Option

The strcoll() function compares the string s1 to the string s2, both interpreted as appropriate to the LC_COLLATE category of the current locale.

Q.7. Which of the following is the variable type defined in header string. h?

Select Your Option

This is the unsigned integral type and is the result of the sizeof keyword.

Q.8. NULL is the macro defined in the header string. h.

Select Your Option

NULL macro is the value of a null pointer constant.

Q.9. What will be the output of the following C code?

const char pla[] = "string1"; 
const char src[] = "string2"; 
printf("Before memmove place= %s, src = %s\n", pla, src); 
memmove(pla, src, 7); 
printf("After memmove place = %s, src = %s\n", pla, src);                        


Select Your Option

In the C library function void *memmove(void *str1, const void *str2, size_t n) copies n characters from str2 to str1.

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

Select Your Option

It is a simple way of creating a C String. You can also define it like the below. \0 is mandatory in this version. char ary[] = {'h','e','l','l','o','\0'};

Q.11. What will be the output of the following C code?

const char str1[]="ABCDEF1234567"; 
const char str2[] = "269"; 
len = strcspn(str1, str2); 
printf("First matching character is at %d\n", len + 1);                        


Select Your Option

size_t strcspn(const char *str1, const char *str2) is used to calculate the length of the initial segment of str1, which consists entirely of characters not in str2.

Q.12. How do you convert this char array to string.?
char str[]={'g','l','o','b','y'};

Select Your Option

Q.13. What is the output of C Program.?

int main() 
{
    int str[]={'g','l','o','b','y'}; 
    printf("A%c ",str); 
    printf("A%s ",str); 
    printf("A%c ",str[0]);
    return 0;
}                   


Select Your Option

Notice that STR is not a string as it is not a char array with null at the end. So STR is the address of array which is converted to Char by %c. If you use %s, it prints the first number converted to char.

Q.14. What is the maximum length of a C String.?

Select Your Option

Maximum size of a C String is dependent on implemented PC memory. C does not restrict C array size or String Length.

Q.15. What is the output of C program with strings.?

int main() 
{
    char str1[]="JOHN";
    char str2[20];
    str2= str1;
    printf("%s",str2);
    return 0; 
}                      


Select Your Option

You can not assign one string to the other. It is an error. " error: assignment to expression with array type

Instructions:-

  1. This Quiz is based on the String Manipulation in C
  2. Each correct answer will carry 2 points
  3. Once an option is selected you cannot select any other, So choose wisely
  4. Do not refresh the page as it will reset the quiz
  5. Once the time is up the quiz will automatically get submitted with no of Question responded
  6. Your total score alongwith your name will be shown after submission of the Quiz
  7. Wish you ALL THE BEST 👍👍

START

Results:-

Hi




Post a Comment

FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP

Previous Post Next Post