Programming in C
Programming in C
4th Edition
ISBN: 9780321776419
Author: Stephen G. Kochan
Publisher: Addison-Wesley
Question
Book Icon
Chapter 13, Problem 1E
Program Plan Intro

Program Plan:

  • Include the necessary header files into program.
  • Declare the “typedef” variable in return type of “integer”.
  • Define the function named “testFunction()” which returns “1” in return type of integer.
  • Define the main method.
    • Define the function.
    • Declare the object for “FunctionPtr”.
    • Call the “testFunction” function and store the result in “objPtr”.
    • Print the result on screen.

Expert Solution & Answer
Check Mark
Program Description Answer

The following program is demonstrates the definition of “typedef” variable which represents a pointer to a function.

Explanation of Solution

Program:

//Include required header files

#include <stdio.h>

/*Definition of typedef function*/

typedef int(*FunctionPtr)(void);

/*Function definition*/

int testFunction(void)

{

//Return statement

return 1;

}

//Main funciton

int main(void)

{

//Function definition

int testFunction(void);

//Object declaration

FunctionPtr objPtr;

//Function is called by pointer

objPtr = testFunction;

//Print statement

printf("%i\n", objPtr());

//Return statement

return 0;

}

Sample Output

1

Want to see more full solutions like this?

Subscribe now to access step-by-step solutions to millions of textbook problems written by subject matter experts!
Students have asked these similar questions
You will be using the "usdata" package's "county" data #  for this assignment. # You will need to run:#  install.packages("usdata")# once to install this library - do not include the#  install.packages command in your submission#  as it can cause gradescope to fail ## ## ## ## ## DO NOT MODIFY BELOW ## ## ## ## ## library(usdata)county<-as.data.frame(county)county<-county[,1:14]county<-county[rowSums(is.na(county))==0,]# The set.seed command will ensure your results are consistent#  each time you run the "source" commandset.seed(311)## ## ## ## ## DO NOT MODIFY ABOVE ## ## ## ## ##  # Treating the "county" dataset as the population of US counties#  create the dataframe "my.SRS" that represents a simple#  random sample of n=250 individual counties from all counties in the US. my.SRS <- NA   # Treating the "county" dataset as the population of US counties#  create the dataframe "my.Stratified" that represents a stratified#  sample of individual counties from all counties in…
Please answer two JAVA OOP problems.
Please answer this JAVA OOP problem.
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Text book image
Systems Architecture
Computer Science
ISBN:9781305080195
Author:Stephen D. Burd
Publisher:Cengage Learning