Sail E0 Webinar

MCQs

Total Questions : 33 | Page 1 of 4 pages
Question 1. What is right way to Initialize array?
  1.    int num[6] = { 2, 4, 12, 5, 45, 5 };
  2.    int n{} = { 2, 4, 12, 5, 45, 5 };
  3.    int n{6} = { 2, 4, 12 };
  4.    int n(6) = { 2, 4, 12, 5, 45, 5 };
 Discuss Question
Answer: Option A. -> int num[6] = { 2, 4, 12, 5, 45, 5 };
Question 2. What will be the output of the program ?
#include
void main()
{
int a[5] = {5, 1, 15, 20, 25};
int i, j, m;
i = ++a[1];
j = a[1]++;
m = a[i++];
printf("%d, %d, %d", i, j, m);
}
  1.    3, 2, 15
  2.    2, 3, 20
  3.    2, 1, 15
  4.    1, 2, 5
 Discuss Question
Answer: Option A. -> 3, 2, 15
Question 3. What will be the output of following program code?
#include
int main(void)
{
char p;
char buf[10] = {1, 2, 3, 4, 5, 6, 9, 8};
p = (buf + 1)[5];
printf("%d", p);
return 0;
}
  1.    5
  2.    6
  3.    9
  4.    Error
  5.    None of the above
 Discuss Question
Answer: Option C. -> 9
Question 4. An array elements are always stored in ________ memory locations.
  1.    Sequential
  2.    Random
  3.    Sequential and Random
  4.    None of the above
 Discuss Question
Answer: Option A. -> Sequential
Question 5. Let x be an array. Which of the following operations are illegal?
I.   ++x
II. x+1
III. x++
IV. x*2
  1.    I and II
  2.    I, II and III
  3.    II and III
  4.    I, III and IV
  5.    III and IV
 Discuss Question
Answer: Option D. -> I, III and IV
Question 6. What is the maximum number of dimensions an array in C may have?
  1.    2
  2.    8
  3.    20
  4.    50
  5.    Theoratically no limit. The only practical limits are memory size and compilers.
 Discuss Question
Answer: Option E. -> Theoratically no limit. The only practical limits are memory size and compilers.
Question 7. Size of the array need not be specified, when
  1.    Initialization is a part of definition
  2.    It is a declaratrion
  3.    It is a formal parameter
  4.    All of these
 Discuss Question
Answer: Option D. -> All of these
Question 8. Consider the following type definition.
typedef char x[10];
x myArray[5];
What will sizeof(myArray) be ? (Assume one character occupies 1 byte)
  1.    15
  2.    10
  3.    50
  4.    30
  5.    None of these
 Discuss Question
Answer: Option C. -> 50
Question 9. What will be printed after execution of the following code?
void main()
{
int arr[10] = {1,2,3,4,5};
printf("%d", arr[5]);
}
  1.    Garbage Value
  2.    5
  3.    6
  4.    0
  5.    None of these
 Discuss Question
Answer: Option D. -> 0
Question 10. What will be the output of the following program?
void main()
{
char str1[] = "abcd";
char str2[] = "abcd";
if(str1==str2)
printf("Equal");
else
printf("Unequal");
}
  1.    Equal
  2.    Unequal
  3.    Error
  4.    None of these.
 Discuss Question
Answer: Option B. -> Unequal

Latest Videos

Latest Test Papers