Programming for Problem Solving (3110003) MCQs

MCQs of Array & String

Showing 21 to 30 out of 35 Questions
21.
What is the output?

int main()
{
    int ary[3][2] = {1,2,3,4,5,6};
    printf("%d,%d", ary[0][0], ary[2][1]);
}

(a) 2,5
(b) 1,6
(c) 1,5
(d) 2,6
Answer:

Option (b)

22.
What is the format specifier used to print a String or Character array in C printf() or scanf () function?
(a) %c
(b) %s
(c) %C
(d) %d
Answer:

Option (b)

23.
What is the output?

void main()
{
    char ary[]="Programming in C";
    printf("%s",ary);
}

(a) Programming in C
(b) P
(c) Programming
(d) Compiler error
Answer:

Option (a)

24.
What is the output?

void main()
{
    char str[25];
    scanf("%s",str);
    printf("%s",str);
}
//input: Programming in C

(a) Programming in C
(b) P
(c) Programming
(d) Compiler error
Answer:

Option (c)

25.
What is the output?

void main()
{
    char str[]={"C","A","T","\0"};
    printf("%s",str);
}

(a) C
(b) CAT
(c) CAT\0
(d) Compiler error
Answer:

Option (d)

26.
What is the output?

void main() 

    char str[2]; 
    int i=0; 
    scanf("%s", str); 
    while(str[i] != '\0') 
    { 
        printf("%c", str[i]); i++; 
    } 

//Input: INDIA

(a) IN
(b) I
(c) INDIA
(d) Compiler error
Answer:

Option (c)

27.
How do you accept a multi-word input in C language.?
(a) scanf()
(b) gets()
(c) getc()
(d) None of these
Answer:

Option (b)

28.
Choose the correct C sentence about strings.
(a) printf() is capable of printing a multi-word string.
(b) puts() is capable of printing a multi-word string.
(c) gets() is capable of accepting a multi-word string.
(d) All of these
Answer:

Option (d)

29.
If the two strings are identical, then strcmp() function returns
(a) -1
(b) 1
(c) 0
(d) True
Answer:

Option (c)

30.
Which function will you choose to merge two words?
(a) strcpy()
(b) strjoin()
(c) strcat()
(d) strmerge()
Answer:

Option (c)

Showing 21 to 30 out of 35 Questions