Write a C# program to find the largest and lowest values from three integer values

  • برمجة سي شارب
  • برمجة

Write a C# program to find the largest and lowest values from three integer values

Sample Output:

Input first integer:                                                   
15                                                                     
Input second integer:                                                  
25                                                                     
Input third integer:                                                   
30                                                                     
Largest of three: 30                                                   
Lowest of three: 15

الأجوبة

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
public class Exercise39 {
static void Main(string[] args)
        {
Console.WriteLine("\nInput first integer:");  
int x = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Input second integer:");  
int y = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Input third integer:");  
int z = Convert.ToInt32(Console.ReadLine());
              
Console.WriteLine("Largest of three: "+Math.Max(x, Math.Max(y, z)));
Console.WriteLine("Lowest of three: "+Math.Min(x, Math.Min(y, z)));
        }
}
هل كان المحتوى مفيد؟

تبحث عن مدرس اونلاين؟

محتاج مساعدة باختيار المدرس الافضل؟ تواصل مع فريقنا الان لمساعدتك بتأمين افضل مدرس
ماهو التخصص الذي تبحث عنه؟
اكتب هنا...