Sunday, March 17, 2013

Array Of Pointers

#include<iostream>
using namespace std;
int main()
{
    int num[5]={2,3,4,5,6};
    int *ptr=num;
    for(int i=0;i<5;++i,++ptr)
    {
        cout<<*ptr<<" ";
    }
    cout<<"\n\n";
    for(int i=0;i<5;++i,++ptr)
    {
        if(num[i]%2==0)
        num[i]=num[i]-1;
        else
        num[i]=num[i]+1;
        cout<<num[i]<<" ";
    }
    return 0;
}

0 comments:

Post a Comment