adplus-dvertising

Welcome to the Strings MCQs Page

Dive deep into the fascinating world of Strings with our comprehensive set of Multiple-Choice Questions (MCQs). This page is dedicated to exploring the fundamental concepts and intricacies of Strings, a crucial aspect of C Programming. In this section, you will encounter a diverse range of MCQs that cover various aspects of Strings, from the basic principles to advanced topics. Each question is thoughtfully crafted to challenge your knowledge and deepen your understanding of this critical subcategory within C Programming.

frame-decoration

Check out the MCQs below to embark on an enriching journey through Strings. Test your knowledge, expand your horizons, and solidify your grasp on this vital area of C Programming.

Note: Each MCQ comes with multiple answer choices. Select the most appropriate option and test your understanding of Strings. You can click on an option to test your knowledge before viewing the solution for a MCQ. Happy learning!

Strings MCQs | Page 4 of 14

Q31.
What will be the output of the program in Turbo C?
#include<stdio.h>

int main()
{
    char str[10] = "CompSci";
    str[6] = "Bits";
    printf("%s\n", str);
    return 0;
}
Discuss
Answer: (d).Error
Q32.
What will be the output of the program ?
#include<stdio.h>

int main()
{
    char str1[] = "Hello";
    char str2[] = "Hello";
    if(str1 == str2)
        printf("Equal\n");
    else
        printf("Unequal\n");
    return 0;
}
Discuss
Answer: (b).Unequal
Q33.
What will be the output of the program ?
#include<stdio.h>

int main()
{
    char t;
    char *p1 = "CompSci", *p2;
    p2=p1;
    p1 = "Bits";
    printf("%s %s\n", p1, p2);
    return 0;
}
Discuss
Answer: (b).Bits CompSci
Q34.
What will be the output of the program ?
#include<stdio.h>
#include<string.h>

int main()
{
    printf("%c\n", "abcdefgh"[4]);
    return 0;
}
Discuss
Answer: (c).e
Q35.
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<stdio.h>

int main()
{
    printf("%u %s\n", &"Hello1", &"Hello2");
    return 0;
}
Discuss
Answer: (a).1022 Hello2
Q36.
Which of the following statements are correct about the program below?
#include<stdio.h>

int main()
{
    char str[20], *s;
    printf("Enter a string\n");
    scanf("%s", str);
    s=str;
    while(*s != '\0')
    {
        if(*s >= 97 && *s <= 122)
            *s = *s-32;
        s++;
    }
    printf("%s",str);
    return 0;
}
Discuss
Answer: (b).The code converts lower case character to upper case
Q37.
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".
Discuss
Answer: (b).2, 3, 4
Q38.
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.
Discuss
Answer: (b).1, 2, 3
Discuss
Answer: (c).strcmp(s1, s2) returns 0 if s1==s2
Q40.
What will be the output of the program ?
#include<stdio.h>
#include<string.h>

int main()
{
    char str1[20] = "Hello", str2[20] = " World";
    printf("%s\n", strcpy(str2, strcat(str1, str2)));
    return 0;
}
Discuss
Answer: (c).Hello World
Page 4 of 14

Suggested Topics

Are you eager to expand your knowledge beyond C Programming? We've curated a selection of related categories that you might find intriguing.

Click on the categories below to discover a wealth of MCQs and enrich your understanding of Computer Science. Happy exploring!