有请高手帮我看下错哪了?
#include <stdio.h>char get_choice ();
char get_first ();
float get_float (void);
float get_add () ;
float get_subtract () ;
float get_multiply ();
float get_divide () ;
main ()
{
int choice;
while ((choice = get_choice ())!= 'q')
{
switch (choice)
{
case 'a': get_add ();
break;
case 's': get_subtract ();
break;
case 'm': get_multiply ();
break;
case 'd': get_divide ();
break;
default : printf ("Program error!\n");
break;
}
}
printf ("Bye.\n");
return 0 ;
}
char get_choice (void)
{
int ch ;
printf ("Enter the operation for your choice:\n");
printf ("a. add s.subtract\n");
printf ("m. multiply d.divide\n");
printf ("q. quit\n");
ch = get_first ();
while (ch != 'a' && ch != 's' && ch != 'm' && ch != 'd' && ch != 'q')
{
printf ("Please respond with a, s, m, d, q.\n");
ch = get_first();
}
return ch ;
}
char get_first ()
{
int ch ;
ch = getchar () ;
while ( getchar () != '\n')
continue ;
return ch ;
}
float get_float (void)
{
float input;
char ch ;
while (scanf("%f", &input) !=1)
{
while ((ch = getchar ()) != '\n')
putchar (ch);
printf (" is not an number.\n");
printf ("Please enter a number, such as 2.5, -1.78E8, or 3: ");
}
return input ;
}
float get_add ()
{
float m , n ;
printf ("Enter first number: ");
m = get_float ();
printf ("Enter second number: ");
n = get_float ();
printf ("%f + %f = %f\n\n", m, n, m+n);
return 0 ;
}
float get_subtract ()
{
float m , n ;
printf ("Enter first number: ");
m = get_float ();
printf ("Enter second number: ");
n = get_float ();
printf ("%f - %f = %f\n\n", m, n, m-n);
return 0 ;
}
float get_multiply ()
{
float m , n ;
printf ("Enter first number: ");
m = get_float ();
printf ("Enter second number: ");
n = get_float ();
printf ("%f * %f = %f\n\n", m, n, m*n);
return 0 ;
}
float get_divide ()
{
float m , n ;
printf ("Enter first number: ");
m = get_float ();
printf ("Enter second number: ");
n = get_float ();
while ( n == 0)
{
printf ("Enter a number other than 0: ") ;
n = get_float () ;
}
printf ("%f / %f = %f\n\n", m, n, m/n);
return 0 ;
}