How to find the Maximum of Three Numbers in C# - Step by Step Examples



How to find the Maximum of Three Numbers in C# ?

Answer

To find the maximum of three numbers in C#, you can use the `Math.Max` method.



✐ Examples

1 Find Maximum of Three Numbers

In this example,

  1. We declare three variables a, b, and c with the numbers to compare.
  2. We use the `Math.Max` method to compare the numbers and get the maximum.

C# Program

using System;
class Program
{
    static void Main()
    {
        int a = 5;
        int b = 8;
        int c = 3;
        int max = Math.Max(Math.Max(a, b), c);
        Console.WriteLine($"Maximum of three numbers is: {max}");
    }
}

Output

Maximum of three numbers is: 8

Summary

In this tutorial, we learned How to find the Maximum of Three Numbers in C# language with well detailed examples.




More C# Comparison Operations Tutorials

  1. How to find the Maximum of Two Numbers in C# ?
  2. How to find the Minimum of Two Numbers in C# ?
  3. How to find the Maximum of Three Numbers in C# ?
  4. How to find the Minimum of Three Numbers in C# ?