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?

  1.     #include <stdio.h>
  2.     struct point
  3.     {
  4.         int x;
  5.         int y;
  6.     };
  7.     void foo(struct point*);
  8.     int main()
  9.     {
  10.         struct point p1[]  =  {1, 2, 3, 4};
  11.         foo(p1);
  12.     }
  13.     void foo(struct point p[])
  14.     {
  15.         printf("%dn", p[1].x);
  16.     }

a) Compile time error
b) 3
c) 2
d) 1

View Answer

Answer: b [Reason:] None.

2. What is the output of this C code?

  1.     #include <stdio.h>
  2.     struct point
  3.     {
  4.         int x;
  5.         int y;
  6.     };
  7.     void foo(struct point*);
  8.     int main()
  9.     {
  10.         struct point p1[] = {1, 2, 3, 4};
  11.         foo(p1);
  12.     }
  13.     void foo(struct point p[])
  14.     {
  15.         printf("%dn", p->x);
  16.     }

a) 1
b) 2
c) 3
d) Compile time error

View Answer

Answer: a [Reason:] None.

3. What is the output of this C code?

  1.     #include <stdio.h>
  2.     struct point
  3.     {
  4.         int x;
  5.         int y;
  6.     };
  7.     void foo(struct point*);
  8.     int main()
  9.     {
  10.         struct point p1[] = {1, 2, 3, 4};
  11.         foo(p1);
  12.     }
  13.     void foo(struct point p[])
  14.     {
  15.         printf("%d %dn", p->x, ++p->x);
  16.     }

a) 1 2
b) 2 2
c) Compile time error
d) Undefined behaviour

View Answer

Answer: b [Reason:] None.

4. What is the output of this C code?

  1.     #include <stdio.h>
  2.     struct point
  3.     {
  4.         int x;
  5.         int y;
  6.     } p[] = {1, 2, 3, 4, 5};
  7.     void foo(struct point*);
  8.     int main()
  9.     {
  10.         foo(p);
  11.     }
  12.     void foo(struct point p[])
  13.     {
  14.         printf("%d %dn", p->x, p[2].y);
  15.     }

a) 1 0
b) Compile time error
c) 1 somegarbagevalue
d) Undefined behaviour

View Answer

Answer: a [Reason:] None.

5. What is the output of this C code?

  1.     #include <stdio.h>
  2.     struct point
  3.     {
  4.         int x;
  5.         int y;
  6.     };
  7.     void foo(struct point*);
  8.     int main()
  9.     {
  10.         struct point p1[] = {1, 2, 3, 4, 5};
  11.         foo(p1);
  12.     }
  13.     void foo(struct point p[])
  14.     {
  15.         printf("%d %dn", p->x, p[3].y);
  16.     }

a) Compile time error
b) 1 0
c) 1 somegarbagevalue
d) None of the mentioned

View Answer

Answer: c [Reason:] None.

6. What is the output of this C code?

  1.     #include <stdio.h>
  2.     struct point
  3.     {
  4.         int x;
  5.         int y;
  6.     };
  7.     void foo(struct point*);
  8.     int main()
  9.     {
  10.         struct point p1[] = {1, 2, 3, 4, 5};
  11.         foo(p1);
  12.     }
  13.     void foo(struct point p[])
  14.     {
  15.         printf("%d %dn", p->x, (p + 2).y);
  16.     }

a) Compile time error
b) 1 0
c) 1 somegarbagevalue
d) Undefined behaviour

View Answer

Answer: a [Reason:] None.

7. What is the output of this C code?

  1.     #include <stdio.h>
  2.     struct point
  3.     {
  4.         int x;
  5.         int y;
  6.     };
  7.     void foo(struct point*);
  8.     int main()
  9.     {
  10.         struct point p1[] = {1, 2, 3, 4, 5};
  11.         foo(p1);
  12.     }
  13.     void foo(struct point p[])
  14.     {
  15.         printf("%d %dn", p->x, (p + 2)->y);
  16.     }

a) Compile time error
b) 1 0
c) 1 somegarbagevalue
d) undefined behaviour

View Answer

Answer: b [Reason:] None.

8. What is the output of this C code?

  1.     #include <stdio.h>
  2.     struct student
  3.     {
  4.         char *c;
  5.     };
  6.     void main()
  7.     {
  8.         struct student s[2];
  9.         printf("%d", sizeof(s));
  10.     }

a) 2
b) 4
c) 16
d) 8

View Answer

Answer: d [Reason:] None.