The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
x
+10 votes
2.4k views

What does the following C-statement declare?

int (*f) (int * );
  1. A function that takes an integer pointer as argument and returns an integer

  2. A function that takes an integer as argument and returns an integer pointer

  3. A pointer to a function that takes an integer pointer as argument and returns an integer

  4. A function that takes an integer pointer as argument and returns a function pointer

asked in Programming by Veteran (69k points)
edited by | 2.4k views

5 Answers

+29 votes
Best answer
  1. A function that takes an integer pointer as argument and returns an integer $\Rightarrow int \ f (int *)$

  2. A function that takes an integer as argument and returns an integer pointer $\Rightarrow int * f (int )$

  3. A pointer to a function that takes an integer pointer as argument and returns an integer $\Rightarrow$

    int (*f) (int * );

So Answer is C

answered by Veteran (49.5k points)
edited by
what will be the declaration for D ?

and for a pointer to a function which takes an integer pointer as argument , and returns an integer pointer.?

1.  declaration for D ("A function that takes an integer pointer as argument and returns a function pointer")
int* f(int *)

 2. for a pointer to a function which takes an integer pointer as argument , and returns an integer pointer.
      int* (*f) (int *)
 

@saurabh rai

1.  declaration for D ("A function that takes an integer pointer as argument and returns a integer pointer")
int* f(int *)

1.  declaration for D ("A function that takes an integer pointer as argument and returns a function pointer")
int ( * f(int *) ) ()

here f returns a pointer pointing to a function which returns int data and takes no input as arguments.

#VS can u write a program on it ??

int ( * f(int *) ) ()

Read this, http://cseweb.ucsd.edu/~ricko/CSE131/rt_lt.rule.html

I call this "Brahmaastra" technique for solving such question.

+6 votes
Answer is option C... This is the proptotype to declare a pointer to a function
answered by Active (1.4k points)
+2 votes
Option c.
answered by Loyal (3.3k points)
+2 votes

http://www.geeksforgeeks.org/complicated-declarations-in-c/

Good information to go through

Answer C

answered by Boss (8.3k points)
+2 votes

By clockwise spiral rule, answer is C

A very good read to read function description http://c-faq.com/decl/spiral.anderson.html

answered by Active (2.3k points)
Answer:

Related questions



Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true

33,687 questions
40,231 answers
114,272 comments
38,803 users