arrow
arrow
arrow
The correct statement for a function that takes a pointer to a float, a pointer to a pointer to a char, and returns a pointer to a pointer to an integ
Question



The correct statement for a function that takes a pointer to a float, a pointer to a pointer to a char, and returns a pointer to a pointer to an integer is:

A.

int **fun(float**, char**)

B.

int *fun(float*, char*)

C.

int **fun(float*, char**)

D.

More than one of the above

E.

None of the above

Correct option is C


The function declaration requires the following:
· Takes a pointer to a float (float*): This means the function should accept an argument of type float*, indicating a pointer to a float.
· Takes a pointer to a pointer to a char (char**): Since the function should accept a pointer to a pointer to a char, one of the arguments must be char**.
· Returns a pointer to a pointer to an integer (int**): The return type of the function must be int**, which matches the return type in option (c).
Thus, the correct function prototype is:
int **fun(float*, char**);
Important Key Points:
1. Function Signature: The function declaration in C/C++ follows the pattern of return_type function_name(parameter_list). Here, int** is the return type, fun is the function name, and (float*, char**) is the parameter list.
2. Pointer to a Float (float*): The function takes a parameter of type float*, which means it accepts a memory address pointing to a float variable.
3. Pointer to a Pointer to a Char (char**): A char** parameter is a pointer to a pointer, often used when modifying string arrays or dynamically allocated memory locations.
4. Returning a Pointer to a Pointer (int**): The function is expected to return an int**, which is a pointer to an integer pointer. This is useful when working with dynamic memory allocation, multi-dimensional arrays, or modifying pointers inside functions.
5. Correct Syntax: The correct function declaration follows pointer rules in C/C++ programming, ensuring type compatibility with arguments and return values.
6. Eliminating Other Options: Options that do not satisfy all three requirements (pointer to float, pointer to pointer to char, and returning pointer to pointer to int) are incorrect.
Knowledge Booster:
· int **fun(float**, char**): Here, the first parameter is float**, which means a pointer to a pointer to a float instead of a pointer to a float (float*).
· int *fun(float*, char*): This function returns int* instead of int** and takes char* instead of char**, which does not match the required function prototype.

Free Tests

Free
Must Attempt

UPTET Paper 1: PYP Held on 23rd Jan 2022 (Shift 1)

languageIcon English
  • pdpQsnIcon150 Questions
  • pdpsheetsIcon150 Marks
  • timerIcon150 Mins
languageIcon English
Free
Must Attempt

UPTET Paper 2 Social Science : PYP Held on 23rd Jan 2022 (Shift 2)

languageIcon English
  • pdpQsnIcon150 Questions
  • pdpsheetsIcon150 Marks
  • timerIcon150 Mins
languageIcon English
Free
Must Attempt

UPTET Paper 2 Maths & Science : PYP Held on 23rd Jan 2022 (Shift 2)

languageIcon English
  • pdpQsnIcon150 Questions
  • pdpsheetsIcon150 Marks
  • timerIcon150 Mins
languageIcon English
test-prime-package

Access ‘BPSC TRE (11-12)’ Mock Tests with

  • 60000+ Mocks and Previous Year Papers
  • Unlimited Re-Attempts
  • Personalised Report Card
  • 500% Refund on Final Selection
  • Largest Community
students-icon
353k+ students have already unlocked exclusive benefits with Test Prime!
Our Plans
Monthsup-arrow