C#: Find the largest and lowest values from three integer values
Largest and Lowest of Three Integers
Write a C# program to find the largest and lowest values from three integer values.

Sample Solution:
C# Sharp Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
public class Exercise39 {
static void Main(string[] args) {
// Prompt the user to input the first integer
Console.WriteLine("\nInput first integer:");
// Read the input and convert it to an integer 'x'
int x = Convert.ToInt32(Console.ReadLine());
// Prompt the user to input the second integer
Console.WriteLine("Input second integer:");
// Read the input and convert it to an integer 'y'
int y = Convert.ToInt32(Console.ReadLine());
// Prompt the user to input the third integer
Console.WriteLine("Input third integer:");
// Read the input and convert it to an integer 'z'
int z = Convert.ToInt32(Console.ReadLine());
// Find and display the largest of the three integers using Math.Max method
Console.WriteLine("Largest of three: " + Math.Max(x, Math.Max(y, z)));
// Find and display the smallest of the three integers using Math.Min method
Console.WriteLine("Lowest of three: " + Math.Min(x, Math.Min(y, z)));
}
}
Sample Output:
Input first integer: 15 Input second integer: 25 Input third integer: 30 Largest of three: 30 Lowest of three: 15
Flowchart:

For more Practice: Solve these Related Problems:
- Write a C# program to find the second largest number among three integers.
- Write a C# program to identify if two or more integers are tied as the largest.
- Write a C# program to sort three integers and print the largest, middle, and smallest.
- Write a C# program to find the difference between the largest and smallest of three integers.
Go to:
PREV : Extract 'PH' from String.
NEXT : Nearest to 20 or Return 0.
C# Sharp Code Editor:
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.