250+ TOP MCQs on Precedence and Order of Evaluation and Answers

C Objective Questions on “Precedence and Order of Evaluation”. One shall practice these Objective Questions to improve their C programming skills needed for various interviews (campus interviews, walkin interviews, company interviews), placements, entrance exams and other competitive exams. These questions can be attempted by anyone focusing on learning C Programming language. They can be a beginner, fresher, engineering graduate or an experienced IT professional. Our C Objective Questions come with detailed explanation of the answers which helps in better understanding of C concepts.

Here is a listing of C Objective Questions on “Precedence and Order of Evaluation” along with answers, explanations and/or solutions:

1. Which of the following operators has an associativity from Right to Left?
a) <=
b) <<
c) ==
d) +=
Answer: d
Clarification: None.

2. Which operators of the following have same precedence?

P. "!=", Q. "+=", R. "<<="

a) P and Q
b) Q and R
c) P and R
d) P, Q and R
Answer: b
Clarification: None.

3. Comment on the following statement.

   n = 1;
   printf("%d, %dn", 3*n, n++);

a) Output will be 3, 2
b) Output will be 3, 1
c) Output will be 6, 1
d) Output is compiler dependent
Answer: d
Clarification: None.

4. Which of the following option is the correct representation of the following C statement?

a) e = (a * (b +(c /(d * f))));
b) e = ((a * b) + (c / (d * f)));
c) e = ((a * b) + ((c / d)* f));
d) Both e = ((a * b) + (c / (d * f))); and e = ((a * b) + ((c / d)* f));
Answer: d
Clarification: Verified by e = 1 * 2 + 3 / 4 * 5; and then using respective braces according to the option.

5. While swapping 2 numbers what precautions to be taken care?

    b = (b / a);
    a = a * b;
    b = a / b;

a) Data type should be either of short, int and long
b) Data type should be either of float and double
c) All data types are accepted except for (char *)
d) This code doesn’t swap 2 numbers
Answer: b
Clarification: None.

6. What will be the output of the following C code?

  1.     #include
  2.     int main()
  3.     {
  4.         int a = 1, b = 2, c = 3, d = 4, e;
  5.         e = c + d = b * a;
  6.         printf("%d, %dn", e, d);
  7.     }

a) 7, 4
b) 7, 2
c) 5, 2
d) Syntax error
Answer: d
Clarification: None.

7. Which of the following is the correct order of evaluation for the given expression?

a) % / * =
b) / * % =
c) = % * /
d) * % / =
Answer: a
Clarification: None.

8. Which function in the following expression will be called first?

a = func3(6) - func2(4, 5) / func1(1, 2, 3);

a) func1();
b) func2();
c) func3();
d) Cannot be predicted
Answer: d
Clarification: None.

9. Which of the following operator has the highest precedence in the following?
a) ()
b) sizeof
c) *
d) +
Answer: a
Clarification: None.

10. Which of the following is a ternary operator?
a) &&
b) >>=
c) ?:
d) ->
Answer: c
Clarification: None.

250+ TOP MCQs on Functions Returning Non-integers and Answers

’s MCQs on C helps anyone preparing for placement in Hexaware and other companies. Anyone looking for Hexaware placement papers should practice these questions continuously for 2-3 months, thereby ensuring a top position in placements.

Here is a listing of online C test questions on “Functions Returning Non-integers” along with answers, explanations and/or solutions:

1. What will be the output of the following C code?

  1.     #include 
  2.     int *m();
  3.     void main()
  4.     {
  5.         int k = m();
  6.         printf("%d", k);
  7.     }
  8.     int *m()
  9.     {
  10.         int a[2] = {5, 8};
  11.         return a;
  12.     }

a) 5
b) 8
c) Nothing
d) Varies
Answer: d
Clarification: None.

2. What will be the output of the following C code?

  1.     #include 
  2.     void m(int k)
  3.     {
  4.         printf("hi");
  5.     }
  6.     void m(double k)
  7.     {
  8.         printf("hello");
  9.     }
  10.     void main()
  11.     {
  12.         m(3);
  13.     }

a) hi
b) hello
c) Compile time error
d) Nothing
Answer: c
Clarification: None.

3. What is the default return type if it is not specified in function definition?
a) void
b) int
c) double
d) short int
Answer: b
Clarification: None.

4. What will be the output of the following C code?

  1.     #include 
  2.     int foo();
  3.     int main()
  4.     {
  5.         int i = foo();
  6.     }
  7.     foo()
  8.     {
  9.         printf("2 ");
  10.         return 2;
  11.     }

a) 2
b) Compile time error
c) Depends on the compiler
d) Depends on the standard
Answer: a
Clarification: None.

5. What will be the output of the following C code?

  1.     #include 
  2.     double foo();
  3.     int main()
  4.     {
  5.         foo();
  6.         return 0;
  7.     }
  8.     foo()
  9.     {
  10.         printf("2 ");
  11.         return 2;
  12.     }

a) 2
b) Compile time error
c) Depends on the compiler
d) Depends on the standard
Answer: b
Clarification: None.

6. Functions can return structure in C?
a) True
b) False
c) Depends on the compiler
d) Depends on the standard
Answer: a
Clarification: None.

7. Functions can return enumeration constants in C?
a) true
b) false
c) depends on the compiler
d) depends on the standard
Answer: a
Clarification: None.

8. What will be the output of the following C code?

  1.     #include 
  2.     enum m{JAN, FEB, MAR};
  3.     enum m foo();
  4.     int main()
  5.     {
  6.         enum m i = foo();
  7.         printf("%dn", i);
  8.     }
  9.     int  foo()
  10.     {
  11.         return JAN;
  12.     }

a) Compile time error
b) 0
c) Depends on the compiler
d) Depends on the standard
Answer: a
Clarification: None.

250+ TOP MCQs on Macro Substitution and Answers

C helps anyone preparing for Dell and other companies C interviews. One should practice these Objective Questions and answers continuously for 2-3 months to clear Dell interviews on C Programming language.

Here is a listing of C programming questions on “Macro Substitution” along with answers, explanations and/or solutions:

1. What will be the output of the following C code?

  1.     #include 
  2.     void main()
  3.     {
  4.         #define max 37;
  5.         printf("%d", max);
  6.     }

a) 37
b) Compile time error
c) Varies
d) Depends on compiler
Answer: b
Clarification: None.

2. What will be the output of the following C code?

  1.     #include 
  2.     void main()
  3.     {
  4.         #define max 37
  5.         printf("%d", max);
  6.     }

a) 37
b) Run time error
c) Varies
d) Depends on compiler
Answer: a
Clarification: None.

3. What will be the output of the following C code?

  1.     #include 
  2.     void main()
  3.     {
  4.         #define const int
  5.         const max = 32;
  6.         printf("%d", max);
  7.     }

a) Run time error
b) 32
c) int
d) const
Answer: b
Clarification: None.

4. What will be the output of the following C code?

  1.     #include 
  2.     void main()
  3.     {
  4.         #define max 45
  5.         max = 32;
  6.         printf("%d", max);
  7.     }

a) 32
b) 45
c) Compile time error
d) Varies
Answer: c
Clarification: None.

5. What will be the output of the following C code?

  1.     #include 
  2.     # define max
  3.     void m()
  4.     {
  5.         printf("hi");
  6.     }
  7.     void main()
  8.     {
  9.         max;
  10.         m();
  11.     }

a) Run time error
b) hi hi
c) Nothing
d) hi
Answer: d
Clarification: None.

6. What will be the output of the following C code?

  1.     #include 
  2.     #define A 1 + 2
  3.     #define B 3 + 4
  4.     int main()
  5.     {
  6.         int var = A * B;
  7.         printf("%dn", var);
  8.     }

a) 9
b) 11
c) 12
d) 21
Answer: b
Clarification: None.

7. Which of the following Macro substitution are accepted in C?
a)

   #define A #define
   A VAR 20

b)

   #define A define
   #A VAR 20

c)

   #define #A #define
   #A VAR 20

d) None of the mentioned
Answer: d
Clarification: None.

8. Comment on the output of the following C code.

  1.     #include 
  2.     #define var 20);
  3.     int main()
  4.     {
  5.         printf("%dn", var
  6.     }

a) No errors, it will show the output 20
b) Compile time error, the printf braces aren’t closed
c) Compile time error, there are no open braces in #define
d) None of the mentioned
Answer: a
Clarification: None.

9. Which of the following properties of #define is not true?
a) You can use a pointer to #define
b) #define can be made externally available
c) They obey scope rules
d) All of the mentioned
Answer: d
Clarification: None.

250+ TOP MCQs on Multidimensional Arrays and Answers

C helps anyone preparing for Symantec and other companies C interviews. One should practice these Objective Questions and answers continuously for 2-3 months to clear Symantec interviews on C Programming language.

Here is a listing of C multiple choice questions on “Multidimensional Arrays” along with answers, explanations and/or solutions:

1. What is the correct syntax to send a 3-dimensional array as a parameter? (Assuming declaration int a[5][4][3];)
a) func(a);
b) func(&a);
c) func(*a);
d) func(**a);
Answer: a
Clarification: None.

2. What are the applications of a multidimensional array?
a) Matrix-Multiplication
b) Minimum Spanning Tree
c) Finding connectivity between nodes
d) All of the mentioned
Answer: d
Clarification: None.

3. What will be the output of the following C code?

  1.     #include 
  2.     int main()
  3.     {
  4.         int ary[2][3];
  5.         foo(ary);
  6.     }
  7.     void foo(int *ary[])
  8.     {
  9.         int i = 10, j = 2, k;
  10.         ary[0] = &i;
  11.         ary[1] = &j;
  12.         *ary[0] = 2;
  13.         for (k = 0;k < 2; k++)
  14.         printf("%dn", *ary[k]);
  15.     }

a) 2 2
b) Compile time error
c) Undefined behaviour
d) 10 2
Answer: a
Clarification: None.

4. What will be the output of the following C code?

  1.     #include 
  2.     int main()
  3.     {
  4.         int ary[2][3];
  5.         foo(ary);
  6.     }
  7.     void foo(int (*ary)[3])
  8.     {
  9.         int i = 10, j = 2, k;
  10.         ary[0] = &i;
  11.         ary[1] = &j;
  12.         for (k = 0;k < 2; k++)
  13.         printf("%dn", *ary[k]);
  14.     }

a) Compile time error
b) 10 2
c) Undefined behaviour
d) segmentation fault/code crash
Answer: a
Clarification: None.

5. What will be the output of the following C code?

  1.     #include 
  2.     int main()
  3.     {
  4.         foo(ary);
  5.     }
  6.     void foo(int **ary)
  7.     {
  8.         int i = 10, k = 10, j = 2;
  9.         int *ary[2];
  10.         ary[0] = &i;
  11.         ary[1] = &j;
  12.         printf("%dn", ary[0][1]);
  13.     }

a) 10
b) 2
c) Compile time error
d) Undefined behaviour
Answer: d
Clarification: None.

6. What will be the output of the following C code?

  1.     #include 
  2.     int main()
  3.     {
  4.         int ary[2][3][4], j = 20;
  5.         ary[0][0] = &j;
  6.         printf("%dn", *ary[0][0]);
  7.     }

a) Compile time error
b) 20
c) Address of j
d) Undefined behaviour
Answer: a
Clarification: None.

7. What will be the output of the following C code?

  1.     #include 
  2.     int main()
  3.     {
  4.         int ary[2][3];
  5.         ary[][] = {{1, 2, 3}, {4, 5, 6}};
  6.         printf("%dn", ary[1][0]);
  7.     }

a) Compile time error
b) 4
c) 1
d) 2
Answer: a
Clarification: None.

250+ TOP MCQs on Arrays of Structures and Answers

C helps anyone preparing for Philips and other companies C interviews on C Programming language.

Here is a listing of C Objective Questions on “Arrays of Structures” along with answers, explanations and/or solutions:

1. What will be the output of the following C code?

  1.     #include 
  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
Answer: b
Clarification: None.

2. What will be the output of the following C code?

  1.     #include 
  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
Answer: a
Clarification: None.

3. What will be the output of the following C code?

  1.     #include 
  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
Answer: b
Clarification: None.

4. What will be the output of the following C code?

  1.     #include 
  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
Answer: a
Clarification: None.

5. What will be the output of the following C code?

  1.     #include 
  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
Answer: c
Clarification: None.

6. What will be the output of the following C code?

  1.     #include 
  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
Answer: a
Clarification: None.

7. What will be the output of the following C code?

  1.     #include 
  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
Answer: b
Clarification: None.

8. What will be the output of the following C code?

  1.     #include 
  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
Answer: d
Clarification: None.

250+ TOP MCQs on Variable Length Argument and Answers

C programming questions on “Variable Length Argument”. One shall practice these questions to improve their C programming skills needed for various interviews (campus interviews, walkin interviews, company interviews), placements, entrance exams and other competitive exams. These questions can be attempted by anyone focusing on learning C Programming language. They can be a beginner, fresher, engineering graduate or an experienced IT professional. Our C programming questions come with detailed explanation of the answers which helps in better understanding of C concepts.

Here is a listing of C programming questions on “Variable Length Argument” along with answers, explanations and/or solutions:

1. What will be the output of the following C code?

  1.     #include 
  2.     #include 
  3.     void func(int, ...);
  4.     int main()
  5.     {
  6.         func(2, 3, 5, 7, 11, 13);
  7.         return 0;
  8.     }
  9.     void func(int n, ...)
  10.     {
  11.         int number, i = 0;
  12.         va_list start;
  13.         va_start(start, n);
  14.         while (i != 3)
  15.         {
  16.             number = va_arg(start, int);
  17.             i++;
  18.         }
  19.         printf("%d", number);
  20.     }

a) 3
b) 5
c) 7
d) 11
Answer: c
Clarification: None.

2. Which of the following function with ellipsis are illegal?
a) void func(…);
b) void func(int, …);
c) void func(int, int, …);
d) none of the mentioned
Answer: a
Clarification: None.

3. Which of the following data-types are promoted when used as a parameter for an ellipsis?
a) char
b) short
c) int
d) none of the mentioned
Answer: a
Clarification: None.

4. Which header file includes a function for variable number of arguments?
a) stdlib.h
b) stdarg.h
c) ctype.h
d) both stdlib.h and stdarg.h
Answer: b
Clarification: None.

5. Which of the following macro extracts an argument from the variable argument list (ie ellipsis) and advance the pointer to the next argument?
a) va_list
b) va_arg
c) va_end
d) va_start
Answer: b
Clarification: None.

6. The type va_list in an argument list is used ________
a) To declare a variable that will refer to each argument in turn;
b) For cleanup
c) To create a list
d) There is no such type
Answer: a
Clarification: None.

7. In a variable length argument function, the declaration “…” can _______
a) Appear anywhere in the function declaration
b) Only appear at the end of an argument list
c) Nothing
d) None of the mentioned
Answer: b
Clarification: None.

8. Each call of va_arg _______
a) Returns one argument
b) Steps va_list variable to the next
c) Returns one argument & Steps va_list variable to the next
d) None of the mentioned
Answer: c
Clarification: None.