D Drsoccerball Well-Known Member Joined May 28, 2014 Messages 3,650 Gender Undisclosed HSC 2015 Apr 23, 2016 #1 How do we find the largest term in an array ?
KingOfActing lukewarm mess Joined Oct 31, 2015 Messages 1,016 Location Sydney Gender Male HSC 2016 Apr 23, 2016 #2 Drsoccerball said: How do we find the largest term in an array ? Click to expand... 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: Apr 23, 2016
Drsoccerball said: How do we find the largest term in an array ? Click to expand... 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;
D Drsoccerball Well-Known Member Joined May 28, 2014 Messages 3,650 Gender Undisclosed HSC 2015 Apr 23, 2016 #3 KingOfActing said: 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 Click to expand... ahaha thanks i figured it out. that wouldn't find the max number ^
KingOfActing said: 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 Click to expand... ahaha thanks i figured it out. that wouldn't find the max number ^