
Keith B. answered 06/29/17
Tutor
4.6
(22)
Software Engineer and Math Geek
1. Count how many angles given will summing them up. If you weren't given just three angles or if they don't all add up to 180, then it cannot make up a triangle.
2. create a temp variable tmp to hold one of the value
tmp=a
a=b
b=tmp
3. set variable highest equal to the first element in the array.
walk the array starting with the 2nd element. If an entry is higher than highest, set highest to the value
4. walk array starting with the 2nd element. if an entry is higher than array[0] use the swap in #2 to switch them
5. this requires two loops
outer walk array starting at 1st element and go to less than size of the array - 1 [ outer < array_size-1]
inner walk array starting at 1 higher than outer walk and go to less than size of array [ inner < array_size ]
if array[outer] < array[inner] swap the values
There is a third way - the array itself may contain a flag to indicate that the end has been reach. For example, null character ('\0') is used to indicate the end of an array of characters.