In: Computer Science
Solution
Code
#include <stdio.h>
//max and min function declarations
int max(int number1, int number2);
int min(int number1, int number2);
int main()
{
int number1, number2, maximum, minimum,choice;//variable
declaration
do
{
printf("\nEnter any two numbers:\n");
scanf("%d%d",&number1,&number2);//user input for two
numbers
printf("\nEnter your choice : 0 for minimum 1 for
maximum\n");
scanf("%d",&choice);//user input for choice
if(choice==0)//if user enters 0 min function will be called
{
minimum = min(number1, number2);//calling min function
printf("Minimum = %d", minimum);
}
else if(choice==1)////if user enters 1 max function will be
called
{
maximum = max(number1, number2);//calling max function
printf("Maximum = %d", maximum);
} // Call minimum function
else
printf("Not valid input");
}while(number1!=-999 && number2!=-999);//if user enters
-999 -999 loop will be stopped
return 0;
}
//max function used to find maximum between two numbers.
int max(int number1, int number2)
{
return (number1 > number2 ) ? number1 : number2;
}
//min function used to find minimum between two numbers.
int min(int number1, int number2)
{
return (number1 > number2 ) ? number2 : number1;
}
Screenshot of the program
Output
--
If you need any further help, please specify, love to help
all the best
please upvote