How do you find the biggest term of a series/sequence. Is it possible to find the biggst number of the output of a loop? Can this be done with a FOR loop? or any loop at all? any suggestions?
Basically I'm going to ouput a series of numbers and then say "the highest term is: "
Here's a simple example. You can play around with entering different numbers in various points within the array, and you'll see that it always comes up with the largest.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
#include <iostream>
usingnamespace std;
int main()
{
int myarray[]={7,4,9,3,1,6};
int bignumber=myarray[0];
for(int i =0; i<6; i++)
{
if(myarray[i]>bignumber)
{
bignumber=myarray[i];
}
}
cout<<bignumber<<endl;
system("pause");
}