Advertisement

C++ Array Program using with loop


In this program, You will learn how to implement Array program using with loop in C++.


for (i = 0; i < 10; i++) {
     cin >> arr[i]; 
}

Example: How to implement Array program using with loop in C++

#include<iostream>
using namespace std;

int main() {

    int arr[10], i;

    cout << "Enter any 5 numbers:";
    for (i = 0; i < 5; i++) {
        cin >> arr[i];
    }

    cout << "All Array is:";
    for (i = 0; i < 5; i++) {
        cout << arr[i] << " ";
    }

    return 0;
}

Output:

Enter any 5 numbers:10 20 30 40 50
All Array is:10 20 30 40 50