C# Sharp Basic Algorithm Exercises: Check the largest number among three given integers
C# Sharp Basic Algorithm: Exercise-18 with Solution
Write a C# Sharp program to check the largest number among three given integers.
Pictorial Presentation:
Sample Solution:
C# Sharp Code:
using System;
namespace exercises
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine(test(1,2,3));
Console.WriteLine(test(1,3,2));
Console.WriteLine(test(1,1,1));
Console.WriteLine(test(1,2,2));
Console.ReadLine();
}
public static int test(int x, int y, int z)
{
var max = Math.Max(x, Math.Max(y, z));
return max;
}
}
}
Sample Output:
3 3 1 2
Flowchart:
C# Sharp Code Editor:
Improve this sample solution and post your code through Disqus
Previous: Write a C# Sharp program to check if a string 'yt' appears at index 1 in a given string. If it appears return a string without 'yt' otherwise return the original string.
Next: Write a C# Sharp program to check which number nearest to the value 100 among two given integers. Return 0 if the two numbers are equal.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
- New Content published on w3resource:
- HTML-CSS Practical: Exercises, Practice, Solution
- Java Regular Expression: Exercises, Practice, Solution
- Scala Programming Exercises, Practice, Solution
- Python Itertools exercises
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework
- Angular - JavaScript Framework
- Vue - JavaScript Framework
- Jest - JavaScript Testing Framework