I need help with this program. I'm trying to report all the numbers higher than the first element of the array that the user inputs. It only prints some of the elements higher than the first element but not all of them. Can someone please help me to fix this program?
Code:#include <iostream.h> int main() { // declare variables float a[10]; int hold; // get floats from user cout << "What are the floating point numbers?" << endl; for(int i = 0; i < 10; i ++) { cin >> a[i]; } // find which numbers have exceeded first elemnet cout << "Numbers that exceed the first element : "; for (int j = 0; j < 10; j++) { if (a[j] > a[1]) { cout << a[j] << " "; } } cin >> hold; return 0; }



LinkBack URL
About LinkBacks


