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;
}
Answer: D
No answer description available for this question.
Enter details here
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;
}
Answer: B
No answer description available for this question.
Enter details here
The strpbrk() function is used to return a pointer to the character, or a null pointer if no character from s2 occurs in s1.
Answer: A
char *strpbrk(const char *s1,const char *s2);
The first occurrence in the string s1 of any character from the string s2 is done by strpbrk().
Enter details here
Predict the output?
#include
int fun(char *str1)
{
char *str2 = str1;
while(*++str1);
return (str1-str2);
}
int main()
{
char *str = "GeeksQuiz";
printf("%d", fun(str));
return 0;
}
Answer: B
No answer description available for this question.
Enter details here
What will be the output of the following C code?
const char str1[] = "abcdef";
const char str2[] = "fgha";
char *mat;
mat= strpbrk(str1, str2);
if(mat)
printf("First matching character: %c\n", *mat);
else
printf("Character not found");
Answer: D
The strpbrk() function is used to locate the first occurrence in the string str1 of any character from the string str2.
Enter details here
What will be the output of the following C code?
const char pla[] = "string1";
const char src[] = "string2";
printf("Before memmove place= %s, src = %s\n", pla, src);
memmove(pla, src, 7);
printf("After memmove place = %s, src = %s\n", pla, src);
Answer: A
In the C library function void *memmove(void *str1, const void *str2, size_t n) copies n characters from str2 to str1.
Enter details here
What will be the output of the following C code?
const char str1[10]="Helloworld";
const char str2[10] = "world";
char *mat;
mat = strstr(str1, str2);
printf("The substring is:%s\n", mat);
Answer: A
The C library function char *strstr(const char *str1, const char *str2) is used to find the first occurrence of the substring str2 in the string str1.The terminating ‘\0’ characters are not compared.
Enter details here
Which among the given options is the right explanation for the statement size_t strcspn(c, s)?
Answer: C
The function size_t strcspn(c, s) is used to return length of prefix of c consisting of characters not in s.
Enter details here
Use_______to determine the null-terminated message string that corresponds to the error code errcode.
Answer: A
Use strerror (errcode) to determine the null-terminated message string that corresponds to the error code errcode.
Enter details here
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;
}
Answer: B
No answer description available for this question.
Enter details here