Top

Strings

11.

Which code from the given option return pointer to last occurrence of c in ch or NULL if not present?

Answer: B

The function char *strrchr(ch, c) returns pointer to last occurrence of c in ch or NULL if not present.

Enter details here

12.

If the size of pointer is 4 bytes then What will be the output of the program ?

#include

int main()
{
    char *str[] = {"Frogs", "Do", "Not", "Die", "They", "Croak!"};
    printf("%d, %d", sizeof(str), strlen(str[0]));
    return 0;
}

 

Answer: C

No answer description available for this question.

Enter details here

13.

What will be the output of the following C code?

#include 
    int main()
    {
        char *str = "hello, world";
        char str1[15] = "hello wo 9";
        strcpy(str, str1);
        printf("%s", str1);
    }

 

Answer: B

No answer description available for this question.
 

Enter details here

14.

Which of the following is the variable type defined in header string. h?

Answer: C

This is the unsigned integral type and is the result of the sizeof keyword.

Enter details here

15.

What will be the output of the following C code?

#include 
    int main()
    {
        char *str = "hello, world\n";
        printf("%d", strlen(str));
 
    }

 

Answer: C

No answer description available for this question.
 

Enter details here

16.

#include  
int main() 
{ 
    char *str1 = "GeeksQuiz"; 
    char str2[] = "GeeksQuiz"; 
  
    printf("sizeof(str1) = %d, sizeof(str2) = %d", 
           sizeof(str1), sizeof(str2)); 
  
    return 0; 
} 

 

Answer: B

No answer description available for this question.
 

Enter details here

17.

What will be the output of the program ?

#include

int main()
{
    char str[] = "India\0BIX\0";
    printf("%d\n", sizeof(str));
    return 0;
}

 

Answer: D

No answer description available for this question.

Enter details here

18.

What will the following C code do?

char * strrchr(const char *s, int c )
char ch = c;
char *sc;
for(sc = NULL; ; ++s)
if(*s == ch)
SC = 9;
i f (*s =='\O' )
return (( char *) s);

 

Answer: A

The strrchr() function locates the last occurrence of c (converted to a char) in the string pointed to by s. String contains null character as a terminating part of it.

Enter details here

19.

#include  
   
void my_toUpper(char* str, int index) 
{ 
    *(str + index) &= ~32; 
} 
   
int main() 
{ 
    char* arr = "geeksquiz"; 
    my_toUpper(arr, 0); 
    my_toUpper(arr, 5); 
    printf("%s", arr); 
    return 0; 
} 

 

Answer: C

No answer description available for this question.
 

Enter details here

20.

In below program, what would you put in place of “?” to print “Quiz”?

#include  
int main()  
{  
  char arr[] = "GeeksQuiz";  
  printf("%s", ?);  
  return 0;  
} 

 

Answer: B

No answer description available for this question.
 

Enter details here

Loading…
Tags: Strings Questions and Answers || Strings MCQ Questions and Answers || Strings GK Questions and Answers || Strings GK MCQ Questions || Strings Multiple Choice Questions and Answers || Strings GK || GK on Strings || C Programming Questions and Answers || C Programming MCQ Questions and Answers || C Programming GK Questions and Answers || GK on C Programming