Using an array in a program - C++ Data Type

C++ examples for Data Type:Array

Description

Using an array in a program

Demo Code

#include <cstdlib> 
#include <iostream> 

using namespace std; 

int main(int argc, char *argv []) 
{ 
   int thisArray [10]; 
   int i; //from  w  ww.j  a v a 2s. c om

   i = 0; 
   while (i<10) 
   { 
      thisArray [i] = 10-i; 
      i++; 
   } 

   i=0; 
   while (i<10) 
   { 
     cout << thisArray [i]; 
     cout << endl; 
     i++; 
   } 

 

   i=9; 
   while (i>=0) 
   { 
      cout << thisArray [i]; 
      cout << endl; 
      i--; 
   } 

 
   return 0; 
}

Result


Related Tutorials