String In C MCQ: Multiple Choice Questions Strings

String In C. Mixed Multiple-Choice Questions on Strings and its types with Programs and Outputs.

 

Which of the following function duplicates a string ??

A. strnset
B. strstr
C. strdup
D. stricmp

 

Which string method helps find the length of the string ??

A. stringLength()
B. strlen
C. strdup
D. both i & ii

 

What is a String in C Language ??

A. String is a new Data Type in C
B. String is an array of Characters with null characters as the last element of an array
C. String is an array of Characters with null character as the first element of the array
D. String is an array of Integers with 0 as the last element of the array

 

Which of the following is format specification for printing String in printf() ??

A. %d
B. %c
C. %f
D. %s

 

A String constant in C terminated by ??

A. ‘\O’
B. ‘\\O’
C. “
D. ” “

 

Choose a correct statement about C String ??

char ary[]=”Hello..!”;

A. Character array, ary is a string
B. ary has no Null character at the end
C. String size is not mentioned
D. String can not contain special characters

 

A string in C is what ??

A. 1-D Array of Character
B. 2-D Array of Character
C. Any of i & ii
D. None of the above

 

int len = strlen (“Alan Poonam) ;
printf(“%s” , len) ;

What would be value of len printed ??

A. 10
B. 11
C. depends on the compiler
D. None of the above

 

What is the Format specifier used to print a String or Character array in C Printf or Scanf function ??
A. %c
B. %C
C. %s
D. %w

 

What C function copies the content of one String into another ??

A. Ssrcopy()
B. stringcopy()
C. strcpy()
D. both i & iI

 

What is the output of the C Program with Strings ??

int main()
{
char ary[]=”Discovery Channel”;
printf(“%s”,ary);
return 0;
}

A. D
B. Discovery Channel
C. Discovery
D. Compiler error

 

This C function copies the content of the source string at the end of the target string ??

A. copycat()
B. strcat()
C. both
D. None of the above

 

What is the output of the C Program ??

int main()
{
char str[]={‘g’,’l’,’o’,’b’,’e’};
printf(“%s”,str);
return 0;
}

A. g
B. globe
C. globe\0
D. None of the above

 

All the characters in the string are stored in ??

A. contiguous memory location
B. discreet memory location
C. both
D. pointer to pointer

 

What would be the output of the C Program with ??

int main()
{
char str[]={‘g’,’l’,’o’,’b’,’y’,’\0′};
printf(“%s”,str);
return 0;
}

A. g
B. globe
C. globe\0
D. Compiler error

 

A one-dimensional array A has indices 1….75. Each element is a string and takes up three memory words. The array is stored at location 1120 decimal. The starting address of A[49] is ??

A. 1264
B. 1164
C. 1167
D. 1267

 

How do you convert this char array to string ??

char str[]={‘g’,’l’,’o’,’b’,’y’};

A. str[5] = 0;
B. str[5] = ‘\0’
C. str[]={‘g’,’l’,’o’,’b’,’y’,’\0′};
D. All the above

 

The string processing-related functions are stored in which header file ??

A. <stdio.h>
B. <conio.h>
C. <string.h>
D. none of these

 

What is the maximum number of dimensions an array in C may have ??

A. Two
B. eight
C. sixteen
D. Theoretically no limit. The only practical limits are memory size and compilers

 

Which in-built function can be used to concatenate given two strings in the C program ??

A. strlen( )
B. strcat( )
C. strstr( )
D. none of these

 

What is the output of the given 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;
}

A. A A A
B. A Ag Ag
C. A*randomchar* Ag Ag
D. Compiler error

 

What will be the address of the arr[2][3] if arr is a 2-D long array of 4 rows and 5 columns and the starting address of the array is 2000 ??

A. 2048
B. 2056
C. 2052
D. 2042

 

Predict the output ??
#include<string.h>
void main()
{
char str1[10]=”abyz”;
int i;
for(i=0; i<4; i++)
{
printf(“%c”,str1[i] – 32);
}
}

A. AB
B. zyba
C. abyz
D. ABYZ

 

What is the output of the C Program with arrays ??

int main()
{
char str[]={“C”,”A”,”T”,”\0″};
printf(“%s”,str);
return 0;
}

A. C
B. CAT
C. CAT\0
D. Compiler error

 

An array can be considered as a set of elements stored in consecutive memory locations but having ??

A. Same data type
B. Different data type
C. Same scope
D. None of these

 

What is the output ??
#include<string.h>
int main()
{
char str1[50]=”abc”, str2[50];
strcpy(str2, strrev(str1));
printf(“Reverse string is : %s”,str2);
return 0;
}

A. abc
B. cba
C. ABC
D. none of these

 

What is the maximum length of a C String ??

A. 32 characters
B. 64 characters
C. 256 characters
D. None of the above

 

Size of the array need not be specified, when ??

A. Initialization is a part of the definition
B. It is a formal parameter
C. It is a declaratrion
D. All of the above

 

What is the output of the C program with strings ??

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

A. JOHN
B. J
C. JOHN\0
D. Compiler error

 

The information about an array used in the program will be stored in ??

A. Symbol Table
B. Activation Record
C. Dope Vector
D. Both A and B

 

What is the output of the C Program with arrays ??

int main()
{
char str[25];
scanf(“%s”, str);
printf(“%s”,str);
return 0;
}
//input: South Africa

A. South
B. South Africa
C. S
D. Compiler error

 

The parameter passing mechanism for an array is ??

A. call by value
B. call by reference
C. call by value-result
D. None of the above

 

What is the output of the C program with strings ??

int main()
{
char str[2];
scanf(“%s”, str);
printf(“%s”,str);
return 0;
}
//Input: South

A. So
B. South
C. Compiler error
D. None of the above

 

What is the output of this program ??

int main()
{
char country[]=”BRAZIL”;
char *ptr;
ptr=country;
while(*ptr != ‘\0’)
{
printf(“%c”, *ptr);
ptr++;
}
return 0;
}

A. B
B. BRAZIL
C. Compiler error
D. None of the above

 

A string that is a formal parameter can be declared ??

A. An array with empty braces
B. A pointer to a character
C. Both A and B
D. None of the above

 

What is the output of the C Program with strings ??
int main()
{
char str[2];
int i=0;
scanf(“%s”, str);
while(str[i] != ‘\0’)
{
printf(“%c”, str[i]);
i++;
}
return 0;
}
//Input: KLMN

A. KL
B. KLMN
C. Compiler error
D. None of the above

 

Strcat function adds null character ??

A. Only if there is space
B. Always
C. Depends on the standard
D. depends on the compiler

 

How do you accept a Multi-Word Input in C Language ??

A. SCANF
B. GETS
C. GETC
D. FINDS

 

What will happen if in a C program you assign a value to an array element whose subscript exceeds the size of the array ??

A. The element will be set to 0.
B. The compiler would report an error.
C. The program may crash
D. None of the above

 

Choose a correct C Statement 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 from the console or command prompt
D) All the above

 

 

Related Posts

 

Leave a Comment

Your email address will not be published. Required fields are marked *

error: Content is protected !!