Foxoyo
Hey..!!
Strings
  Practice
MCQs
Quizzes
About
Leaderboard
Amazon Books
53
MCQs
0
Attempts
0 %
Accuracy
share
Filter by
Type here
Apply
Which of the following function is more appropriate for reading in a multi-word string
scanf();
printf();
puts();
gets();
What will be the output of the program
#include
#include
int main()
{
char str1[5], str2[5];
int i;
gets(str1);
gets(str2);
i = strcmp(str1, str2);
printf("%d\n", i);
return 0;
}
-1
Error
Unpredictable integer value
What will be the output of the program
#include
int main()
{
char t;
char *p1 = "India", *p2;
p2=p1;
p1 = "BIX";
printf("%s %s\n", p1, p2);
return 0;
}
BIX BIX
BIX India
India India
India BIX
Which of the following statements are correct about the program below
#include
int main()
{
char str[20], *s;
printf("Enter a string\n");
scanf("%s", str);
s=str;
while(*s != '\0')
{
if(*s >= 97 && *s
Error in code
The code converts a string in to an integer
The code converts lower case character to upper case
The code converts upper case character to lower case
What will be the output of the program
#include
int main()
{
printf("India", "BIX\n");
return 0;
}
BIX
India BIX
india
Error
What will be the output of the program
#include
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;
}
ello
HelloHello
Hello
No output
What will be the output of the program (Turbo C in 16 bit platform DOS)
#include
#include
int main()
{
char *str1 = "India";
char *str2 = "BIX";
char *str3;
str3 = strcat(str1, str2);
printf("%s %s\n", str3, str1);
return 0;
}
Error
IndiaBIX IndiaBIX
India India
IndiaBIX India
Which of the following statements are correct
1
A string is a collection of characters terminated by '\0'
2
The format specifier %s is used to print a string
3
The length of the string can be obtained by strlen()
4
The pointer CANNOT work on string
2, 4
1, 2, 3
1, 2
3, 4
What will be the output of the program
#include
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;
}
No output
The string is empty
The string is not empty
How will you print \n on the screen
printf('\n');
echo "\\n";
printf("\\n");
printf("\n");
What will be the output of the program
#include
#include
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;
}
Half of the sentence will get printed
None of above
The sentence will get printed in same order as it entered
The sentence will get printed in reverse order
If the size of pointer is 32 bits What will be the output of the program
#include
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;
}
12, 22, 2
10, 22, 2
11, 41, 1
10, 41, 2
What will be the output of the program
#include
#include
int main()
{
printf("%d\n", strlen("123456"));
return 0;
}
2
7
6
12
What will be the output of the program If characters 'a', 'b' and 'c' enter are supplied as input
#include
int main()
{
void fun();
fun();
printf("\n");
return 0;
}
void fun()
{
char c;
if(
(c = getchar())!= '\n')
fun();
printf("%c",
c);
}
cba
bca
Infinite loop
abc abc
What will be the output of the program in 16-bit platform (Turbo C under DOS)
#include
int main()
{
printf("%d, %d, %d", sizeof
(3.0f), sizeof('3'), sizeof
(3.0));
return 0;
}
10, 3, 4
8, 1, 4
4, 2, 8
4, 2, 4
What will be the output of the program
#include
int main()
{
char p[] = "%d\n";
p[1] = 'c';
printf(p, 65);
return 0;
}
65
C
A
The library function used to find the last occurrence of a character in a string is
laststr()
strrchr()
strnstr()
strstr()
Which of the following function is used to find the first occurrence of a given string in another string
strnset()
strchr()
strstr()
strrchr()
What will be the output of the program
#include
int main()
{
char str[] = "Nagpur";
str[0]='K';
printf("%s, ", str);
str = "Kanpur";
printf("%s", str+1);
return 0;
}
Error
Kagpur, anpur
Nagpur, Kanpur
Kagpur, Kanpur
What will be the output of the program
#include
#include
int main()
{
char str1[20] = "Hello", str2[20] = " World";
printf("%s\n", strcpy(str2, strcat(str1, str2)));
return 0;
}
Hello World
Hello
world
WorldHello
1
2
3
Next
take a quick Quiz
Practice mcqs on Strings
Let's start
pick difficulty level
all
1
2
3
4
5
53
Mcqs
0
attempts
0
followers
Related Topics
Strings
Strings Regular Expressions
Python Strings
C Arrays and Strings
Suggested Books