Question

In: Computer Science

Code in C Write a program whose inputs are three integers, and whose outputs are the...

Code in C

Write a program whose inputs are three integers, and whose outputs are the largest of the three values and the smallest of the three values.

Ex: If the input is:

7 15 3

the output is:

largest: 15 
smallest: 3

Your program must define and call the following two functions. The LargestNumber function should return the largest number of the three input values. The SmallestNumber function should return the smallest number of the three input values.
int LargestNumber(int userNum1, int userNum2, int userNum3)
int SmallestNumber(int userNum1, int userNum2, int userNum3)

Solutions

Expert Solution

File: ls.c

#include <stdio.h>
int LargestNumber(int userNum1, int userNum2, int userNum3);
int SmallestNumber(int userNum1, int userNum2, int userNum3);
int main()
{
   int a,b,c, largest, smallest;//declaring variable
   //Accepting input from user
   printf("\nEnter First Number:");
   scanf("%d",&a);
   printf("\nEnter Second Number:");
   scanf("%d",&b);
   printf("\nEnter Third Number:");
   scanf("%d",&c);
   //calling function
   largest = LargestNumber(a,b,c);
   smallest = SmallestNumber(a,b,c);  
   //display output
   printf("\nThe Largest Number: %d", largest);
   printf("\nThe Smallest Number: %d", smallest);
   return(0);
}
//function for finding largest number
int LargestNumber(int userNum1, int userNum2, int userNum3)
{
   if(userNum1 > userNum2 && userNum1 > userNum3)
       return userNum1;
   else if(userNum2 > userNum3)
       return userNum2;
   else
       return userNum3;
}
//function for finding smallest number
int SmallestNumber(int userNum1, int userNum2, int userNum3)
{
   if(userNum1 < userNum2 && userNum1 < userNum3)
       return userNum1;
   else if(userNum2 < userNum3)
       return userNum2;
   else
       return userNum3;
}

Screen:


Related Solutions

CORAL LANGUAGE ONLY Write a program whose inputs are three integers, and whose outputs are the...
CORAL LANGUAGE ONLY Write a program whose inputs are three integers, and whose outputs are the largest of the three values and the smallest of the three values. If the input is 7 15 3, the output is: largest: 15 smallest: 3 Your program should define and call two functions: Function LargestNumber(integer num1, integer num2, integer num3) returns integer largestNum Function SmallestNumber(integer num1, integer num2, integer num3) returns integer smallestNum The function LargestNumber should return the largest number of the...
Write a program whose inputs are three integers, and whose outputs are the largest of the three values and the smallest of the three values.
 in Coral Simulator  Write a program whose inputs are three integers, and whose outputs are the largest of the three values and the smallest of the three values. If the input is 7 15 3, the output is: largest: 15 smallest: 3 Your program should define and call two functions: Function LargestNumber(integer num1, integer num2, integer num3) returns integer largestNum Function SmallestNumber(integer num1, integer num2, integer num3) returns integer smallestNum The function LargestNumber should return the largest number of the...
Write a program Write a program whose inputs are three integers, and whose output is the...
Write a program Write a program whose inputs are three integers, and whose output is the smallest of the three values. Ex: If the input is: 7 15 3 the output is: 3 C++ please
Write a program whose inputs are three integers, and whose output is the smallest of the...
Write a program whose inputs are three integers, and whose output is the smallest of the three values
Write a program whose inputs are three integers, and whose output is the smallest of the...
Write a program whose inputs are three integers, and whose output is the smallest of the three values. Use else-if selection and comparative operators such as '<=' or '>=' to evaluate the number that is the smallest value. If one or more values are the same and the lowest value your program should be able to report the lowest value correctly. Don't forget to first scanf in the users input. Ex: If the input is: 7 15 3 the output...
in coral write a program whose inputs are three integers, and whose output is the largest...
in coral write a program whose inputs are three integers, and whose output is the largest of the three values. Ex: If the input is 7 15 3, the output is: 15
Program must be in Python Write a program in Python whose inputs are three integers, and...
Program must be in Python Write a program in Python whose inputs are three integers, and whose output is the smallest of the three values. Input is 7 15 3
Write a program whose inputs are two integers, and whose output is the smallest of the...
Write a program whose inputs are two integers, and whose output is the smallest of the two values. Ex: If the input is: 7 15 output is: 7 passed through command line *in python
Write a C++ program that inputs a sequence of integers into a vector, computes the average,...
Write a C++ program that inputs a sequence of integers into a vector, computes the average, and then outputs the # of input values, the average, and the values themselves. There are 0 or more inputs values, followed by a negative value as the sentinel; the negative value is not stored and not counted. The following sample input: 10 20 0 99 -1 would produce the following output: N: 4 Avg: 32.25 10 20 0 99 The main program has...
Write a C++ program that inputs a sequence of integers into a vector, computes the average,...
Write a C++ program that inputs a sequence of integers into a vector, computes the average, and then outputs the # of input values, the average, and the values themselves. There are 0 or more inputs values, followed by a negative value as the sentinel; the negative value is not stored and not counted. The following sample input: 10 20 0 99 -1 would produce the following output: N: 4 Avg: 32.25 10 20 0 99 The main program has...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT