shahina, please learn how to use CODE tags before you post any more code
http://www.codeguru.com/forum/misc.php?do=bbcode
Printable View
shahina, please learn how to use CODE tags before you post any more code
http://www.codeguru.com/forum/misc.php?do=bbcode
hi everybody thanks for helping me solve the program i got the max and min values
int[] marks = new int[10];
int temp = 0;
int max = 0;
int min = 0;
Console.WriteLine("enter the marks of ten students and i will tell u which is maximum and minimum");
for (int x = 0; x < marks.Length; x++)
{
marks[x] =Convert.ToInt32(Console.ReadLine());
}
for (int i = 0; i < marks.Length; i++)
{
for (int y = 0; y < marks.Length; y++)
{
if (marks[i] < marks[y])
{
temp = marks[i];
marks[i] = marks[y];
marks[y] = temp;
}
}
}
Console.WriteLine("The numbers in the sorted order are : ");
for (int x = 0; x < marks.Length; x++)
{
Console.WriteLine("{0}", marks[x]);
}
Console.ReadLine();
min = marks[0];
max = marks[9];
Console.WriteLine("{0} is the minimum value and {1} is the maximum value ", marks[0], marks[9]);
Console.ReadLine();
Code:for (int i = 0; i < marks.Length; i++)
{
// Don't sort, just test for marks[i] > max and marks[i] < min
// and set the min and max values.
}