Find second largest number from an array in C# || Interview Program

preview_player
Показать описание
Hello Friends In this video we will learn how to find second/first largest number from given array in C#.Net

Please Subscribe our channel for new video and give your feedback through comment

#csharpinterviewquestions
#csharpinterviewprograms
#topinterviewquestionsonCSharp
#topinterviewquestionsonaspnet
#InterviewProgram
#dkinterviewpoint
Рекомендации по теме
Комментарии
Автор

Code has been updated of this video, Link is available in the description box for the updated code.

InterviewPoint
Автор

Inspired from you even I have started Sharing my Interview Experience with different Mnc's

DrunkenEngineer
Автор

Please keep a debug point and explain bro

krajasrikar
Автор

very good program but please explain well..

harshsaxena
Автор

int max1 = int.MinValue, max2 = int.MinValue;
for (int i = 0; i < arr.Length; i++)
{
if (arr[i]>max1)
max1 = arr[i];
else if (arr[i]>max2 && arr[i]!=max1)
max2 = arr[i];
}

Console.WriteLine(max2);

abhiksingh
Автор

it not works on 0, 5, 1, 2, 1, 5..
first and second both shows 5 output

MuhammadAbbas-pdsf
Автор

int max1, max2;
int[] arr = { 12, 30, 32, 85, 80, 90, 98, 78, 74 };

for(int i=0;i<arr.Length; i++)
{
Console.WriteLine(arr[i]);
}
max1 = max2 = arr[0];

for(int i=0; i<arr.Length ; i++) {
if (arr[i]>max1)
{
max2 = max1;
max1 = arr[i];
}
else
{
max2 = arr[i];
}
}
Console.WriteLine("First Largest Number : "+max1);

Console.WriteLine("Second Largest Number : " + max2);
Console.ReadLine();



Sir, I have written this code with reference to this video
the out put should be first one will be 98 and second one will be 90 but it is giving the second output :78

AbhilashYadavSanghsevak