20120113

How to use Pointer Arithmatic in C++

Program in c to learn pointer in C
#include<iostream>
using namespace std;
int main()
{
int num[]={10,20,30,40,50};
int *ptr1;
ptr1=num;//assigning the base address of array of integer
cout<<"Array elements are: \n";
int i;
for(i=0;i<5;i++)
{
cout<<num[i];
cout<<"\n";
}
return 0;
}
Previous                             Home                               Next

No comments:

Post a Comment