Sunday, 8 April 2018

Write a program that uses pointers to print the 5 values of an array.

#include<iostream>
#include<conio.h>
using namespace std;
int main ()
{
int arry[5],*ptr;
for(int i=0;i<5;i++)
{
cout<<"Enter the number:";
cin>>arry[i];
}
cout<<"Your entered values are:"<<endl;
ptr=&arry[0];
for(int i=0;i<5;i++)
{
cout<<*ptr++<<endl;
}
}

No comments:

Post a Comment