This section has Multiple Choice Questions on Strings in C Language.
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
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
A. SCANF
B. GETS
C. GETC
D. FINDS
A. Only if there is space
B. Always
C. Depends on the standard
D. depends on the compiler
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
A. An array with empty braces
B. A pointer to a character
C. Both A and B
D. None of the above
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
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
A. call by value
B. call by reference
C. call by value-result
D. None of the above
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