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.

Expert's answer

#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");}
LATEST TUTORIALS
APPROVED BY CLIENTS