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 3 of 14

Explore more Topics under C Programming

Q21.
What will be the output of the program ?
#include<stdio.h>

int main()
{
    char str[25] = "CompSciBits";
    printf("%s\n", &str+2);
    return 0;
}
Discuss
Answer: (a).Garbage value
Q22.
What will be the output of the program ?
#include<stdio.h>

int main()
{
    char str = "CompSciBits";
    printf("%s\n", str);
    return 0;
}
Discuss
Answer: (a).Error
Q23.
What will be the output of the program ?
#include<stdio.h>

int main()
{
    char str[] = "Nagpur";
    str[0]='K';
    printf("%s, ", str);
    str = "Kanpur";
    printf("%s", str+1);
    return 0;
}
Discuss
Answer: (d).Error
Q24.
What will be the output of the program ?
#include<stdio.h>

int main()
{
    printf(5+"CompSciBits\n");
    return 0;
}
Discuss
Answer: (c).ciBits
Q25.
What will be the output of the program ?
#include<stdio.h>
#include<string.h>

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;
}
Discuss
Answer: (b).The sentence will get printed in reverse order
Q26.
What will be the output of the program ?
#include<stdio.h>
void swap(char *, char *);

int main()
{
    char *pstr[2] = {"Hello", "CompSciBits"};
    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;
}
Discuss
Answer: (c).Hello CompSciBits
Q27.
What will be the output of the program (Turbo C in 16 bit platform DOS) ?
#include<stdio.h>
#include<string.h>

int main()
{
    char *str1 = "CompSci";
    char *str2 = "Bits";
    char *str3;
    str3 = strcat(str1, str2);
    printf("%s %s\n", str3, str1);
    return 0;
}
Discuss
Answer: (b).CompSciBits CompSciBits
Q28.
If the size of pointer is 4 bytes then What will be the output of the program ?
#include<stdio.h>

int main()
{
    char *str[] = {"Frogs", "Do", "Not", "Die", "They", "Croak!"};
    printf("%d, %d", sizeof(str), strlen(str[0]));
    return 0;
}
Discuss
Answer: (c).24, 5
Q29.
What will be the output of the program ?
#include<stdio.h>

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;
}
Discuss
Answer: (b).The string is empty
Q30.
What will be the output of the program ?
#include<stdio.h>
#include<string.h>

int main()
{
    char str1[5], str2[5];
    int i;
    gets(str1);
    gets(str2);
    i = strcmp(str1, str2);
    printf("%d\n", i);
    return 0;
}
Discuss
Answer: (a).Unpredictable integer value

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!