C++ Array Stores the numbers from 100 to 600 in an array

Introduction

then prints elements using the new method of array subscripting.

#include <iostream>
using namespace std;
void main()/*from   w ww.j a  v  a 2s. c  o  m*/
{
   int num[6] = {100, 200, 300, 400, 500, 600};
   cout << "num[0] is \t" << num[0] << "\n";
   cout << "(num+0)[0] is \t" << (num+0)[0] << "\n";
   cout << "(num-2)[2] is \t" << (num-2)[2] << "\n\n";
   cout << "num[1] is \t" << num[1] << "\n";
   cout << "(num+1)[0] is \t" << (num+1)[0] << "\n\n";
   cout << "num[5] is \t" << num[5] << "\n";
   cout << "(num+5)[0] is \t" << (num+5)[0] << "\n";
   cout << "(num+2)[3] is \t" << (num+2)[3] << "\n\n";
   cout << "(3+num)[1] is \t" << (3+num)[1] << "\n";
   cout << "3+num[1] is \t" << 3+num[1] << "\n";
   return;
}



PreviousNext

Related