Generic selectors
Exact matches only
Search in title
Search in content
Search in posts
Search in pages
Filter by Categories
nmims post
Objective Type Set
Online MCQ Assignment
Question Solution
Solved Question
Uncategorized

1. What is the output of this C code (considering sizeof char is 1 and pointer is 4)?

  1.     #include <stdio.h>
  2.     int main()
  3.     {
  4.         char *a[2] = {"hello", "hi"};
  5.         printf("%d", sizeof(a));
  6.         return 0;
  7.     }

a) 9
b) 4
c) 8
d) 10

View Answer

Answer: c [Reason:] None.

2. What is the output of this C code?

  1.     #include <stdio.h>
  2.     int main()
  3.     {
  4.         char a[2][6] = {"hello", "hi"};
  5.         printf("%d", sizeof(a));
  6.         return 0;
  7.     }

a) 9
b) 12
c) 8
d) 10

View Answer

Answer: b [Reason:] None.

3. What is the output of this C code?

  1.     #include <stdio.h>
  2.     int main()
  3.     {
  4.         char a[2][6] = {"hello", "hi"};
  5.         printf("%s", *a + 1);
  6.         return 0;
  7.     }

a) hello
b) hi
c) ello
d) ello hi

View Answer

Answer: c [Reason:] None.

4. What is the output of this C code?

  1.     #include <stdio.h>
  2.     int main()
  3.     {
  4.         char *a[2] = {"hello", "hi"};
  5.         printf("%s", *(a + 1));
  6.         return 0;
  7.     }

a) hello
b) ello
c) hi
d) ello hi

View Answer

Answer: c [Reason:] None.

5. Advantage of a multi-dimension array over pointer array.
a) Pre-defined size.
b) Input can be taken from user.
c) Faster Access.
d) All of the mentioned

View Answer

Answer: d [Reason:] None.

6. Which of the following operation is possible using a pointer char?
    (Assuming declaration char *a;)
a) Input via %s
b) Generation of multidimensional array
c) Changing address to point at another location
d) All of the mentioned

View Answer

Answer: c [Reason:] None.

7. Comment on the following two operations?
    int *a[] = {{1, 2, 3}, {1, 2, 3, 4}}; //- 1
    int b[4][4] = {{1, 2, 3}, {1, 2, 3, 4}};//- 2
a) 1 will work, 2 will not
b) 1 and 2, both will work
c) 1 won’t work, 2 will work
d) Neither of them will work

View Answer

Answer: c [Reason:] None.

8. Comment on the following two operations?
    int *a[] = {{1, 2, 3}, {1, 2, 3, 4}}; //- 1
    int b[][] = {{1, 2, 3}, {1, 2, 3, 4}}; //- 2
a) 1 works, 2 doesn’t
b) 2 works, 1 doesn’t
c) Both of them work
d) Neither of them work

View Answer

Answer: d [Reason:] None.