write a C program that prompts the user for three numbers, finds the largest and smallest number and prompts the three numbers entered, the largest number and the smallest number. However, you should read the three numbers in your main program, echo them in the main program then pass the three numbers to a subprogram. Your subprogram should calculate the largest and smallest number in the three entries and return them to the calling program. Remember that since you are returning two values, you need a five element argument list (3 inputs and 2 results) so that you should use pointers where appropriate. The calling program must finally echo the smallest and largest number.
my code is:
- Code: Select all
#include <stdio.h>
int main ()
{
int first, second, third, *min;
printf("\nEnter three integers:");
scanf("%i,%i,%i", &first, &second, &third);
findminimum( first, second, third, *min );
return 0;
}
int findminimum( first, second, third, *min )
{
first = *min;
if( second < *min )
{
second=*min;
}
if( third<*min )
{
third=*min;
}
printf ("The minimum of three numbers is: %i", *min);
return 0;
}
but, it gives the error below:
ÖmerFarukBODURQ3.c:14:44: error: expected ‘)’ before ‘*’ token
I gave 1 hour but could not fix it..
Please help me to find my error...
Thanks in advance