diff --git a/.vs/DSA-open-source/v17/.wsuo b/.vs/DSA-open-source/v17/.wsuo new file mode 100644 index 000000000..28b36bab8 Binary files /dev/null and b/.vs/DSA-open-source/v17/.wsuo differ diff --git a/.vs/DSA-open-source/v17/DocumentLayout.json b/.vs/DSA-open-source/v17/DocumentLayout.json new file mode 100644 index 000000000..c46da2020 --- /dev/null +++ b/.vs/DSA-open-source/v17/DocumentLayout.json @@ -0,0 +1,12 @@ +{ + "Version": 1, + "WorkspaceRootPath": "C:\\Users\\MAYANK\\source\\repos\\DSA-open-source\\", + "Documents": [], + "DocumentGroupContainers": [ + { + "Orientation": 0, + "VerticalTabListWidth": 256, + "DocumentGroups": [] + } + ] +} \ No newline at end of file diff --git a/algorithms/CSharp/src/Arrays/LargestElement.cs b/algorithms/CSharp/src/Arrays/LargestElement.cs new file mode 100644 index 000000000..587575c1d --- /dev/null +++ b/algorithms/CSharp/src/Arrays/LargestElement.cs @@ -0,0 +1,64 @@ +/****************************************************************************** + Program to compute the largest element in array +******************************************************************************/ + +using System; + +class LargestElementFinder +{ + static void Main() + { + const int maxSize = 100; + int[] array = new int[maxSize]; + int size; + int max; + + // Reading the size of the array + Console.Write("Enter the size of the array: "); + size = Convert.ToInt32(Console.ReadLine()); + + // Reading the elements of array + Console.WriteLine($"Enter the {size} elements of the array: "); + for (int i = 0 ; i < size ; i++) + { + Console.Write($"Element [{i}]: "); + array[i] = Convert.ToInt32(Console.ReadLine()); + } + + // Printing the array + Console.WriteLine("The input array: "); + for (int i = 0 ; i < size ; i++) + { + Console.Write(array[i] + " "); + } + + // Assigning the first element of the array to max variable + max = array[0]; + + // Checking for elements greater than the value of max variable + for (int i = 1 ; i < size ; i++) + { + if (array[i] > max) + { + max = array[i]; + } + } + + // Printing out the result + Console.WriteLine($"\nThe largest element of the array: {max}"); + } +} + +/****************************************************************************** + OUTPUT SAMPLE + Enter the size of the array: 5 + Enter the 5 elements of the array: + Element [0]: 1 + Element [1]: 7 + Element [2]: 2 + Element [3]: 5 + Element [4]: 4 + The input array: + 1 7 2 5 4 + The largest element of the array: 7 +******************************************************************************/ \ No newline at end of file