c programming MCQ 22226 pointers questions and answers | Msbte | I scheme pdf
1. Which function is not called in the following program?
-                   #include <stdio.h>
-                   void first() 
-                   {
-                   printf("first"); 
-                   }
-                   void second() 
-                   {
-                   first(); 
-                   }
-                   void third() 
-                   {
-                   second(); 
-                   }
-                   void main() 
-                   {
-                   void (*ptr)(); 
-                   ptr = third; 
-                   ptr(); 
-                   }
  a) Function first
b) Function second
c) Function third
d) None of the   mentioned 
  2. How to call a function without using the function name to send   parameters?
a) typedefs
b) Function pointer
c) Both (a) and   (b)
d) None of the mentioned 
  3. Correct syntax to pass a Function Pointer as an argument
a) void pass(int (*fptr)(int, float, char)){}
b) void pass(*fptr(int, float, char)){}
c) void pass(int (*fptr)){}
d) void   pass(*fptr){} 
  4. Which of the following is not possible in C?
a) Array of function pointer
b)   Returning a function pointer
c)   Comparison of function pointer
d) None of   the mentioned 
5. What is the output of this C code?
-                   #include <stdio.h>
-                   void first() 
-                   {
-                   printf("Hello World"); 
-                   }
-                   void main() 
-                   {
-                   void *ptr() = first; 
-                   ptr++
-                   ptr(); 
-                   }
  a) Illegal application of ++ to void data type
b) pointer   function initialized like a variable
c)   Both (a) and (b)
d) None of the mentioned 
6. What is the output of this C code?
-                   #include <stdio.h>
-                   int mul(int a, int b, int c) 
-                   {
-                   return a * b * c; 
-                   }
-                   void main() 
-                   {
-                   int (*function_pointer)(int, int, int); 
-                   function_pointer = mul; 
-                   printf("The product of three numbers is:%d", 
-                   function_pointer(2, 3, 4)); 
-                   }
  a) The product of three numbers is:24
b)   Run time error
c) Nothing
d) Varies 
7. What is the output of this C code?
-                   #include <stdio.h>
-                   int mul(int a, int b, int c) 
-                   {
-                   return a * b * c; 
-                   }
-                   void main() 
-                   {
-                   int (function_pointer)(int, int, int); 
-                   function_pointer = mul; 
-                   printf("The product of three numbers is:%d", 
-                   function_pointer(2, 3, 4)); 
-                   }
  a) The product of three numbers is:24
b)   Compile time error
c) Nothing
d) Varies 
8. What is the output of this C code?
-                   #include <stdio.h>
-                   void f(int (*x)(int)); 
-                   int myfoo(int); 
-                   int (*fooptr)(int); 
-                   int ((*foo(int)))(int); 
-                   int main() 
-                   {
-                   fooptr = foo(0); 
-                   fooptr(10); 
-                   }
-                   int ((*foo(int i)))(int) 
-                   {
-                   return myfoo; 
-                   }
-                   int myfoo(int i) 
-                   {
-                   printf("%d\n", i + 1); 
-                   }
  a) 10
b) 11
c) Compile time error
d) Undefined   behaviour 

 
Comments
Post a Comment