Docstoc

array manipulation using indexing

Document Sample
array manipulation using indexing Powered By Docstoc
					/* This program uses array manipulation using indexing */



#include <iostream.h>
#include <stdlib.h>
void main(void)
{
    int c[5], v[10];
    int multi [5][10];
    int *ptr;                  // A normal 'int' pointer
    ptr = *multi;           // 'ptr' is assigned the starting address of
the first row

    /* Initialize the array elements */
    for(int i=0; i < 6; i++)
    {
        for (int j=0; j < 10; j++)
        {
                multi[i][j] = i * j;
        }
    }

    /* Array manipulation using indexing */
    cout << "\n Array manipulated using indexing is: \n";
    for(int i=2; i <6; i++)
    {
        for (int j=1; j < 10; j++)
        {
                cout << multi[i][j] << '\t';
        }
        cout << '\n';
    }

     //Array manipulation using pointer
    cout << "\n Array manipulated using pointer is: \n";
    for(int k=0; k < 50; k++, ptr ++)                // 5 * 10 = 50
    {
        cout << *ptr << '\t';
    }



system("PAUSE");
}

				
DOCUMENT INFO
Shared By:
Stats:
views:7
posted:9/20/2012
language:
pages:1
Description: array manipulation using indexing