position

closed account (o10S216C)
Last edited on
Use tags (to make it look purdy), when you click "new post", there will be a thing beside the little bow that says "Format:" with a bunch of buttons, for code click the <> button and put the code between the things that come up with code and /code in square brackects.
closed account (o10S216C)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
    
63     int low = findLowNumber(numbers, SIZE);
// Function to find the lowest number
87 int findLowNumber(int numbers[], int SIZE)
88 {
89 int lownumber = numbers[0];
90 for (int i = 0; i < SIZE; i++)
91 {
92 if (numbers[i] < lownumber)
93 {
94 lownumber = numbers[i];
95 }
96 }
97 return lownumber;
98 }
Last edited on
Those are line numbers?!?! I was wondering what the numbers on the side were, you don't need to include those, as you can now see, when you post code, it makes line numbers automatically.
change line 94 to lownumber = i;.
closed account (o10S216C)
and will that mess up my function on finding the lowest number and displaying it?
closed account (o10S216C)
Last edited on
closed account (o10S216C)
IGNORE those lines, i took it from some other program but it doesn't work so just IGNORE lines 64-71.

1
2
3
4
5
6
7
8
    64     for (int n = 0; n < SIZE; n++)
    65     {
    66        if (numbers[n] < minVal)
    67        {
    68           minVal = numbers[n];
    69           minIndex = n;
    70        }
    71     }
add another function:
1
2
3
4
5
6
7
int findLowIndex(int numbers[], int SIZE){
	int lownumber = 0;
	for (int i = 0; i < SIZE; i++)
		if (numbers[i] < lownumber)
			lownumber = i;
	return lownumber;
}
closed account (o10S216C)
i keep getting 0
Last edited on
whoops replace line 4 of the function with:
if (numbers[i] < numbers[lownumber])
closed account (o10S216C)
THANK YOU
closed account (o10S216C)
Last edited on
1
2
int leninbytes=(char*)(numbers+SIZE)-(char*)numbers;
int leninelems=leninbytes/sizeof(int);
Topic archived. No new replies allowed.