Access element in an array one by one with for loop and array index - C++ Data Type

C++ examples for Data Type:Array

Description

Access element in an array one by one with for loop and array index

Demo Code

#include <iostream>
using namespace std;
int main()/*  www  .ja  v  a 2 s.c o m*/
{
   const int ARRAYSIZE = 5;
   int i, grade[ARRAYSIZE] = {98, 87, 92, 79, 85};
   for (i = 0; i < ARRAYSIZE; i++)
      cout << "\nElement " << i << " is " << grade[i];
   cout << endl;
   return 0;
}

Result


Related Tutorials