Friday, 10 February 2017

Traversing an array in C++?

#include<iostream>
#include<string>

using namespace
std;
int main()
{
 int arr[5];
 for (int i = 0; i < 5; ++i) {
  cout << "Enter the " << i + 1 << "number : " << endl;
  cin >> arr[i];
 }
 cout << "The out put is :" << endl;
 for (int i = 0; i < 5; ++i) {
  cout << "The element at the location " << i << " is " << arr[i] << endl;
 }

 system("pause");
 return 0;
}

No comments:

Post a Comment