Errors in the Given Program
C++ language (Article) (Program)
11Program:
int numbers[5]; for (int i = 0; i <= 5; i++) { cin >> riumbers[i]; }
Output:
Explanation:
Identified Errors
-
Array index out of range
-
Loop condition should be
i < 5, noti <= 5
-
-
Variable name misspelled
-
riumbers[i]should benumbers[i]
-
CORRECTED VERSION:
#include using namespace std; int main() { int numbers[5]; for (int i = 0; i < 5; i++) { cin >> numbers[i]; } cout << "First element is: " << numbers[0] << endl; return 0; }