C# Program to find Biggest of Three Numbers
You are Here:
Find Biggest of Three Numbers
In the following example, we will find which of the following numbers (40, 25, 7) is the biggest number.
Example
C# Compiler
using System;
namespace myApp
{
class Program
{
static void Main(string[] args)
{
int a = 40;
int b = 25;
int c = 7;
Console.WriteLine("The numbers are a = {0}, b = {1}, c = {2}", a, b, c);
if((a > b) && (a > c))
Console.WriteLine("a = {0} is the biggest number", a);
else if(b > c)
Console.WriteLine("b = {0} is the biggest number", b);
else
Console.WriteLine("c = {0} is the biggest number", c);
}
}
}
Output
The numbers are a = 40, b = 25, c = 7
a = 40 is the biggest number
Find Biggest of any Given Three Numbers
In the following example, we will find the biggest of any given three numbers.
Example
C# Compiler
using System;
namespace myApp
{
class Program
{
static void Main(string[] args)
{
Console.Write("Enter an integer for a = ");
int a = Convert.ToInt32(Console.ReadLine());
Console.Write("Enter an integer for b = ");
int b = Convert.ToInt32(Console.ReadLine());
Console.Write("Enter an integer for c = ");
int c = Convert.ToInt32(Console.ReadLine());
if((a > b) && (a > c))
Console.WriteLine("\na = {0} is the biggest number", a);
else if(b > c)
Console.WriteLine("\nb = {0} is the biggest number", b);
else
Console.WriteLine("\nc = {0} is the biggest number", c);
}
}
}
Output
Enter an integer for a = 5
Enter an integer for b = 10
Enter an integer for c = 12
c = 12 is the biggest number
Reminder
Hi Developers, we almost covered 90% of String functions and Interview Question on C# with examples for quick and easy learning.
We are working to cover every Single Concept in C#.
Please do google search for:
Join Our Channel
Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.
This channel is primarily useful for Full Stack Web Developer.