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

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

int main()
{
    static char str1[] = "dills";
    static char str2[20];
    static char str3[] = "Daffo";
    int i;
    i = strcmp(strcat(str3, strcpy(str2, str1)), "Daffodills");
    printf("%d\n", i);
    return 0;
}

a.

0

b.

1

c.

2

d.

4

Discuss
Answer: (a).0
Q12.
What will be the output of the program ?
#include<stdio.h>
#include<string.h>

int main()
{
    static char s[] = "Hello!";
    printf("%d\n", *(s+strlen(s)));
    return 0;
}
Discuss
Answer: (b).0
Q13.
What will be the output of the program ?
#include<stdio.h>

int main()
{
    static char s[25] = "The cocaine man";
    int i=0;
    char ch;
    ch = s[++i];
    printf("%c", ch);
    ch = s[i++];
    printf("%c", ch);
    ch = i++[s];
    printf("%c", ch);
    ch = ++i[s];
    printf("%c", ch);
    return 0;
}
Discuss
Answer: (a).hhe!
Q14.
What will be the output of the program in 16-bit platform (Turbo C under DOS) ?
#include<stdio.h>

int main()
{
    printf("%d, %d, %d", sizeof(3.0f), sizeof('3'), sizeof(3.0));
    return 0;
}
Discuss
Answer: (b).4, 2, 8
Q15.
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 empty\n");
    else
        printf("The string is not empty\n");
    return 0;
}
Discuss
Answer: (b).The string is not empty
Q16.
If char=1, int=4, and float=4 bytes size, What will be the output of the program ?
#include<stdio.h>

int main()
{
    char ch = 'A';
    printf("%d, %d, %d", sizeof(ch), sizeof('A'), sizeof(3.14f));
    return 0;
}
Discuss
Answer: (b).1, 4, 4
Q17.
If the size of pointer is 32 bits What will be the output of the program ?
#include<stdio.h>

int main()
{
    char a[] = "Visual C++";
    char *b = "Visual C++";
    printf("%d, %d\n", sizeof(a), sizeof(b));
    printf("%d, %d", sizeof(*a), sizeof(*b));
    return 0;
}
Discuss
Answer: (c).11, 4 1, 1
Q18.
What will be the output of the program ?
#include<stdio.h>

int main()
{
    static char mess[6][30] = {"Don't walk in front of me...", 
                               "I may not follow;", 
                               "Don't walk behind me...", 
                               "Just walk beside me...", 
                               "And be my friend." };

    printf("%c, %c\n", *(mess[2]+9), *(*(mess+2)+9));
    return 0;
}
Discuss
Answer: (b).k, k
Q19.
What will be the output of the program ?
#include<stdio.h>

int main()
{
    char str1[] = "Hello";
    char str2[10];
    char *t, *s;
    s = str1;
    t = str2;
    while(*t=*s)
        *t++ = *s++;
    printf("%s\n", str2);
    return 0;
}
Discuss
Answer: (a).Hello
Q20.
What will be the output of the program ?
#include<stdio.h>

int main()
{
    char str[] = "India\0BIX\0";
    printf("%d\n", sizeof(str));
    return 0;
}
Discuss
Answer: (d).11
Page 2 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!