English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

2 answers

This entirely depends on what language you are using (please specify the language I know you probably forgot but it is important)

But what you basically need to do is create an empty variable at the start of a loop. This will hold the largest number.

Now do a for loop that runs through the array. This loop should constantly be comparing the value in that particular array slot with the variable you created above. At the end of the process you will find the largest number.

Something like

greatestnumber=0;

for (i=0;i if thearray[i]>greatestnumber{
greatestnumber = thearray[i];
}
}

print "The greatest number is "+greatestnumber;

2006-10-26 20:21:51 · answer #1 · answered by Anonymous · 0 0

Well I dont know which Language you want me to write the code!
But the Solution in general is!
arr[] = '1,2,3,4....';
max = arr[0]; // Assuming tyhe first one is the largest
for(i=0;i<=10;i++)
{
if(max < arr[i]) //comparing with all the numbers in the Array
max=arr[i]; //if true the assigning that number to be the max
}
print max; // Printing the number which is the largest

2006-10-27 03:24:10 · answer #2 · answered by Anurag Bhatia 4 · 0 0

fedest.com, questions and answers