• Congratulations to the Class of 2024 on your results!
    Let us know how you went here
    Got a question about your uni preferences? Ask us here

C code array help. (1 Viewer)

KingOfActing

lukewarm mess
Joined
Oct 31, 2015
Messages
1,016
Location
Sydney
Gender
Male
HSC
2016
How do we find the largest term in an array ?
I don't know C but the pseudocode is:

Code:
int temp = array[0]
for each int i in array
    if (i > temp)
    {
        temp = i;
    }
return temp
I tried to learn C syntax for this:

Code:
int temp = array[0];
int size = sizeof(array)/sizeof(int);

for(int index = 0; index < size; index++)
{
    if(array[index] > maximum)
        maximum = array[index];
}
return maximum;
 
Last edited:

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Top