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;
}
#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;
}
No comments:
Post a Comment