The______ function returns the number of characters that are present before the terminating null character.
Answer: B
The strlen() function is used to return the number of characters that are present before the terminating null character.size-t strlen(const char *s);The length of the string pointed to by s is computed by strlen().
Enter details here
What is the output of following program?
# include
int main()
{
char str1[] = "GeeksQuiz";
char str2[] = {'G', 'e', 'e', 'k', 's', 'Q', 'u', 'i', 'z'};
int n1 = sizeof(str1)/sizeof(str1[0]);
int n2 = sizeof(str2)/sizeof(str2[0]);
printf("n1 = %d, n2 = %d", n1, n2);
return 0;
}
Answer: A
No answer description available for this question.
Enter details here
What will be the output of the program ?
#include
#include
int main()
{
static char str1[] = "dills";
static char str2[20];
static char str3[] = "Daffo";
int i;
i = strcmp(strcat(str3, strcpy(str2, str1)), "Daffodills");
printf("%d\n", i);
return 0;
}
Answer:
Enter details here
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;
}
Answer: A
No answer description available for this question.
Enter details here
What will be the output of the following C code?
char str1[15];
char str2[15];
int mat;
strcpy(str1, "abcdef");
strcpy(str2, "ABCDEF");
mat= strncmp(str1, str2, 4);
if(mat< 0> 0)
printf("str2 is is not greater than str1");
else
printf("both are equal");
Answer: B
The C library function int strncmp(const char *str1, const char *str2, size_t n) is used to compare at most the first n bytes of str1 and str2.
Enter details here
What will be the output of the program ?
#include
#include
int main()
{
char str[] = "India\0\BIX\0";
printf("%d\n", strlen(str));
return 0;
}
Answer: C
No answer description available for this question.
Enter details here
What will strcmp() function do?
Answer: B
The strcmp() function compares the string s1 to the string s2.
int strcmp(const char *s1,const char *s2);
Enter details here
What will be the output of the program ?
#include
int main()
{
char p[] = "%d\n";
p[1] = 'c';
printf(p, 65);
return 0;
}
Answer: A
No answer description available for this question.
Enter details here
What will be the output of the program ?
#include
int main()
{
char *names[] = { "Suresh", "Siva", "Sona", "Baiju", "Ritu"};
int i;
char *t;
t = names[3];
names[3] = names[4];
names[4] = t;
for(i=0; i<=4; i++)
printf("%s,", names[i]);
return 0;
}
Answer: B
No answer description available for this question.
Enter details here
The C library function _________ breaks string s1 into a series of tokens using the delimiter s2.
Answer: A
The C library function char *strtok(char *s1, const char *s2) breaks string s1 into a series of tokens using the delimiter s2.
Enter details here