C MCQ set number 00706

1. The return-type used in String operations are.
a) void only
b) void and (char *) only
c) void and int only
d) void, int and (char *) only

Answer

Answer: d [Reason:] None.

2. String operation such as strcat(s, t), strcmp(s, t), strcpy(s, t) and strlen(s) heavily     rely upon.
a) Presence of NULL character
b) Presence of new-line character
c) Presence of any escape sequence
d) None of the mentioned

Answer

Answer: a [Reason:] None.

3. Which pre-defined function returns a pointer to the last occurence of a character in     a string?
a) strchr(s, c);
b) strrchr(s, c);
c) strlchr(s, c);
d) strfchr(s, c);

Answer

Answer: b [Reason:] None.

4. Which of the following function compares 2 strings with case-insensitively?
a) strcmp(s, t)
b) strcmpcase(s, t)
c) strcasecmp(s, t)
d) strchr(s, t)

Answer

Answer: c [Reason:] None.

5. What will be the value of var for the following?
    var = strcmp(“Hello”, “World”);
a) -1
b) 0
c) 1
d) strcmp has void return-type

Answer

Answer: a [Reason:] None.

6. What is the output of this C code?

  1.     #include <stdio.h>
  2.     int main()
  3.     {
  4.         char str[10] = "hello";
  5.         char *p = strrchr(str, 'l');
  6.         printf("%cn", *(++p));
  7.     }

a) l
b) o
c) e
d) Compilation error

Answer

Answer: b [Reason:] None.

ed010d383e1f191bdb025d5985cc03fc?s=120&d=mm&r=g

DistPub Team

Distance Publisher (DistPub.com) provide project writing help from year 2007 and provide writing and editing help to hundreds student every year.