Knowee
Questions
Features
Study Tools

Which of the following is a valid way to declare a pointer to a function in C?   *1 pointint (*func)(int, int);int *func(int, int);int func(int, int)*;int func(int, int);

Question

Which of the following is a valid way to declare a pointer to a function in C?   *1 pointint (*func)(int, int);int func(int, int);int func(int, int);int func(int, int);

🧐 Not the exact question you are looking for?Go ask a question

Solution

The valid way to declare a pointer to a function in C is:

int (*func)(int, int);

Here's why:

  • int (*func)(int, int); This is the correct way to declare a function pointer. It says that func is a pointer to a function taking two int parameters and returning an int.

  • int *func(int, int); This is not a function pointer. It's a function declaration for a function that takes two int parameters and returns a pointer to an int.

  • int func(int, int)*; This is not valid syntax in C.

  • int func(int, int); This is a function declaration, not a function pointer. It declares a function that takes two int parameters and returns an int.

This problem has been solved

Similar Questions

Which code provides the correct way to declare a function pointer?1 point(void*) function (*);void (*) function (void data) = 12;void (*function)(int data);int * function();

Which of the following function declarations correctly accepts a pointer to an integer as an argument?Marks : 1Negative Marks : 0Answer herevoid func(int &x);void func(int *x);void func(int x);void func(int &*x);

Select the correct answerWhich of the following is the correct way to declare a pointer to an integer in C?Optionsint *ptr;integer *ptr;ptr *int;point int *ptr;

What is the correct syntax to declare a pointer in C++?int &ptr;int ptr*;int *ptr;int ptr&;

Question 7Which code correctly calls a function, given a function pointer variable, fptr, that has no parameters and is type void?1 point*fptr = 2;2 = *(fptr & 0x2);(*fptr)();(fptr)(*);fptr();

1/3

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.