This sample program will get the Maximum element in an array.
Explaination: Using loop and a temporary variable, say temp. Initaially, we set temp equal to list[0]. Then, we compare temp to each array component, from list[1] to list[10]. If we find an array component greater than the current value of temp, we set temp is equal to that component.
Activity
Create a program that will get the smallest value of ann array. Refer your solution in the given example above.
No comments:
Post a Comment