I need to write a menu driven program that allows a user to enter five numbers and then choose between finding the smallest, largest, sum, or average.(adsbygoogle = window.adsbygoogle || []).push({});

So far I have this, which still gives me lots of errors, and I'm not even sure if I can fix it.

Code (Text):#include <stdio.h>

#include <stdlib.h>

void getData (float*a, float*b, float*c);

float calc(int option, float a, float b, float c);

int main (void)

{

int option;

do

{

option = getOption();

if (option != 5)

getData (&a, &b ,&c);

calc (option, a, b, c);

}

while();

return 0;

}

int getOption (void)

{

printf("Menu\n1- Smallest\n2- Largest\n3- Sum\n4- Avg");

scanf("%d", &option);

return option;

}

float calc (int option, float a, float b, float c)

{

float result;

switch (option)

{

case 1: result = smallest (a, b, c);

break;

case 2: result = largest (a, b, c);

break;

case 3: result = Sum (a, b, c);

break;

case 4: result = Avg (a, b, c);

break;

}

result = 1.0;

return result;

}

void getData (float*a, float*b, float*c)

{ printf("Enter 3 numbers: ");

scanf("%f %f %f", &a, &b, &c);

return 0;

}

float smallest (float a, float b, float c)

{

if (a<b && a<c)

return a;

else if (b<a && b<c)

return b;

}

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

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!

# Calculator-like program

Loading...

Similar Threads - Calculator program | Date |
---|---|

Program in FORTRAN which calculate the detection efficiency | Nov 28, 2014 |

A problem when calculating the average of an array (c programming )? | May 1, 2013 |

Hi,Below is a fortran program to calculate the roots of an | Aug 9, 2011 |

Can someone write me a small wxPython program - Simple calculation | Apr 10, 2011 |

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