19 April, 2012

W.A.P using an array pointer displays the negative element in the array

12. using an array pointer into an integer n. Show entered the screen sequence. The screen displays the negative element in the array with its corresponding position.




# include 
using namespace std;
void main ()
{
int * p;
int n, i;
cout << "Enter n integers:";
cin >> n;
p = new int [n];
for (i = 0; i <n; i + +)
{
cout << "enter an integer collection" << i +1 << "=";
cin >> * (p + i);
}
cout << "hen am, the material and their location" << endl;
for (i = 0; i <n; i + +)
if (* (p + i) <0)
{
cout << * (p + i) << endl;
cout << (p + i) << endl;
}
}

No comments:

Post a Comment

Thanks