I have just been introduced to a new chapter in C and I'm a bit confused/lost.
I'm constructing a program that will prompt the user for three integers and then determine the largest and the smallest.
Code:
#include <stdio.h>
void largest();//determines the largest integer entered of 3 inputs
void smallest();//determines the smallest integer of 3 inputs
int main(void)
{
int input1, input2, input3;
printf("Enter 3 integers with a space in between : ");
scanf("%d %d %d", &input1, &input2, &input3);
if((input1 >= input2) && (input1 >= input3))//if the first input is the largest
{
largest();
if(input2 <= input3)//if the first input is the largest and the second input the smallest
smallest();
else if(input3 <= input2)//if the first input is the largest and the third input the smallest
smallest();
}
else if((input2 >= input1) && (input2 >= input3))//if the second input is the largest
{
largest();
if(input1 <= input3)//if the second input is the largest and the first input the smallest
smallest();
else if(input3 <= input1)//if the second input is the largest and the third input the smallest
smallest();
}
else if((input3 >= input1) && (input3 >= input2))//if the third input is the largest
{
largest();
if(input1 <= input2)//if the third input is the largest and the first input the smallest
smallest();
else if(input2 <= input1)//if the third input is the largest and the second input the smallest
smallest();
}
return 0;
}
void largest()
{
int large;
printf("Among the numbers you entered\n");
printf("the largest was %d and the smallest was ", large);//should be printed when the largest intger is determined
}
void smallest()
{
int small;
printf("%d.", small);//should be printed when the smallest integer is printed
}