Skip to content
This repository was archived by the owner on May 29, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .vs/DSA-open-source/v17/.wsuo
Binary file not shown.
12 changes: 12 additions & 0 deletions .vs/DSA-open-source/v17/DocumentLayout.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"Version": 1,
"WorkspaceRootPath": "C:\\Users\\MAYANK\\source\\repos\\DSA-open-source\\",
"Documents": [],
"DocumentGroupContainers": [
{
"Orientation": 0,
"VerticalTabListWidth": 256,
"DocumentGroups": []
}
]
}
64 changes: 64 additions & 0 deletions algorithms/CSharp/src/Arrays/LargestElement.cs
Original file line number Diff line number Diff line change
@@ -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
******************************************************************************/