Stores the numbers from 100 to 600 in an array, then prints elements using the new method of array subscripting. - C++ Data Type

C++ examples for Data Type:Array

Description

Stores the numbers from 100 to 600 in an array, then prints elements using the new method of array subscripting.

Demo Code

#include <iostream>
using namespace std;
void main()/*from ww w .j  a v  a 2  s  . c  om*/
{
   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;
}

Result


Related Tutorials