how do i determine the smallest nr of an input of three hours in a 2D array?
the program is that you must have an input of 3 hours for 3 modules for each studend(4)
how do i determine the smallest nr of an input of three hours in a 2D array?
the program is that you must have an input of 3 hours for 3 modules for each studend(4)
So you want to find the smallest number in an array. First, create an int that will contain the smallest value and set its initial value to the first array element. Then loop through the remaining array elelments, test if the element is smaller than the counter. If it is smaller, then set the counter to equal the value of that array element.
Example:
int nums[5] = {5,4,3,2,1};
int counter = nums[0];
int i;
for(i = 1; i < 5; i++)
{
if( counter > nums[i] )
counter = nums[i];
}