Answer to Question #39111 in C++ for Verasak Sitawan

Question #39111
Write C++ program that declares an array of 10 integers. Write a loop that accepts 10
values from the keyboard, and write another loop that displays the 10 values. Do not
use any subscripts within the two loops; use pointers only.
1
Expert's answer
2017-04-04T08:15:29-0400
#include <iostream>
#include <stdlib.h>

using namespace std;

int main (void)
{
const int SIZE = 10;
int array[SIZE];
cout << "Enter " << SIZE << " numbers:" << endl;
for (int *p = array; p < array + SIZE; ++p)
{
cin >> *p;
}
cout << endl << "The numbers:" << endl;
for (int *p = array; p < array + SIZE; ++p)
{
cout << *p << endl;
}
system("pause");
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS