(this is basically a dumbed-down version for the sake of clarity, but gives the same problem I'm getting)(adsbygoogle = window.adsbygoogle || []).push({});

I have a subfunction called by main, named calculate, which calls two other subfunctions ("findSum" and "findQuotient") and then returns their data to main. "findSum" calculates the sum of two numbers and then returns its data to calculate. "findQuotient" does the same, except it returns the quotient instead. The difficulty is that "findSum" is an integer and "findQuotient" is a float. So if I wanted to return both of these using calculate, what would my prototype and function declaration, etc. have to look like? If it needs pointers, I'd appreciate some advice since I haven't mastered those yet.

My error message is "In function calculate: warning: return makes integer from pointer without a cast"

Here's an example (input/output to user removed for ease):

=======================================================

#include <stdio.h>

int calculate (int integer1, int integer2);

int findSum(int integer1, int integer2);

float findQuotient(float integer1, float integer2);

int main(void)

{

int integer1, integer2;

int sum;

float quotient;

calculate(integer1, integer2)

return 0;

}

int calculate(integer1, integer2)

{

sum(integer1, integer2);

divide(integer1, integer2);

return sum, divide;

}

int findSum(integer1, integer2)

{

int sum;

sum = integer1 + integer2;

return sum;

}

float findQuotient(integer1, integer2)

{

float quotient;

quotient = (float)integer1 / integer2;

return quotient;

}

=============================================

I just typed this up, so please ignore any syntax errors, etc. I appreciate the help, thanks.

**Physics Forums - The Fusion of Science and Community**

Dismiss Notice

Join Physics Forums Today!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# Subfunctions returning different types together (in C)

Loading...

Similar Threads for Subfunctions returning different | Date |
---|---|

Difference in order of execution and design in SQL Server. | Saturday at 3:11 PM |

C/++/# Functions and Return statement in C | May 3, 2017 |

JavaScript Algorithm to return all subarrays of a given array | Jul 1, 2016 |

Functions and their return... | Dec 30, 2015 |

Collect2: ld returned 1 exit status | Nov 19, 2015 |

**Physics Forums - The Fusion of Science and Community**