int smallindex = 0;
int secsmallindex = 0;
I put the lines above into gobalslope.
The rest of the code:
#include <iostream> 
using namespace std;
int main() {
    int list[10] = { 33,6,3,4,55,22,5,6,7,6 };
    for (int a = 1; a <= 10; a++)
    {
        if (smallindex > list[a]) {
            secsmallindex = smallindex;
            smallindex = a;
        }
        else if (list[a] < secsmallindex && list[a] > smallindex) {
            secsmallindex = a;
        }
    }
    cout << secsmallindex << "   " << smallindex;
}
I want to find the second smallest elements and smallest number.
But it can not find it.
The output is 2 and 10.
 
     
     
    