Introduction :
Write a C# program to input elements in an array from user, find maximum and minimum element in array. C program to find biggest and smallest elements in an array. Logic to find maximum and minimum element in array in C# programming.
C# program to find maximum and minimum element in array :
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace array_maximum { class Program { static void Main(string[] args) { int d; int n; float large, small; int[] x= new int[40]; Console.WriteLine("Enter the size of the Array"); n = int.Parse(Console.ReadLine()); Console.WriteLine("Enter the array elements"); for (int i = 0; i < n; i++) { x[i]= int.Parse(Console.ReadLine()); } Console.Write(""); large = x[0]; small = x[0]; for (int i = 1; i < n; i++) { if (x[i] > large) large = x[i]; else if (x[i] < small) small = x[i]; } Console.WriteLine("Large element in array {0}", large); Console.WriteLine("Small element in array {0}", small); } } }
OutPut of Program :
Learn Recommended posts :
How do you reverse a string in C#
C# program to Check String is palindrom or not
How to print Pyramid Pattern in C#
How do you count the no of digits or character in C#
Factorial Number Program in C# using Recursion
Convert string to char array in C#
Finding the biggest of three numbers in C#
C# Program to Check Whether the Entered Number is an Armstrong Number or Not
2 Comments