Sail E0 Webinar

MCQs

Total Questions : 33 | Page 3 of 4 pages
Question 21. If the two strings are identical, then strcmp() function returns
  1.    1
  2.    0
  3.    -1
  4.    true
  5.    None of these
 Discuss Question
Answer: Option B. -> 0
Question 22. The library function used to find the last occurrence of a character in a string is
  1.    laststr()
  2.    strstr()
  3.    strnstr()
  4.    strrchr()
  5.    None of these
 Discuss Question
Answer: Option D. -> strrchr()
Question 23. Which of the following function is used to find the first occurrence of a given string in another string?
  1.    strchr()
  2.    strrchr()
  3.    strstr()
  4.    strnset()
  5.    None of these
 Discuss Question
Answer: Option C. -> strstr()
Question 24. Which of the following function is more appropriate for reading in a multi-word string?
  1.    scanf()
  2.    gets()
  3.    printf()
  4.    puts()
  5.    None of these
 Discuss Question
Answer: Option B. -> gets()
Question 25. What will be the output of the program ?
#include
#include
void main()
{
char str1[20] = "Hello", str2[20] = " World";
printf("%s", strcpy(str2, strcat(str1, str2)));
}
  1.    Hello World
  2.    World
  3.    WorldHello
  4.    Hello
  5.    None of these
 Discuss Question
Answer: Option A. -> Hello World
Question 26. What will be the output of the program ?
#include
void main()
{
printf(5+"Good Morningn");
}
  1.    Good Morning
  2.    M
  3.    Good
  4.    Morning
  5.    None of these
 Discuss Question
Answer: Option D. -> Morning
Question 27. Which of the following correctly accesses the seventh element stored in arr, an array with 100 elements?
  1.    arr[6]
  2.    arr[7]
  3.    arr{6}
  4.    arr{7}
  5.    None of these
 Discuss Question
Answer: Option A. -> arr[6]
Question 28. What will be the output of the program ?
#include
#include
void main()
{
char str[] = "Exam\0Veda";
printf("%s", str);
}
  1.    Exam
  2.    Exam Veda
  3.    Exam\0Veda
  4.    Veda
  5.    None of these
 Discuss Question
Answer: Option A. -> Exam
Question 29. What is the return value of the following statement if it is placed in C program? strcmp("ABC", "ABC");
  1.    33
  2.    -1
  3.    1
  4.    0
  5.    Compilation Error
 Discuss Question
Answer: Option D. -> 0
Question 30. Int a[5] = {1,2,3}
What is the value of a[4]?
  1.    3
  2.    1
  3.    2
  4.    0
  5.    Garbage Value
 Discuss Question
Answer: Option D. -> 0

Latest Videos

Latest Test Papers