Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 825769
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T03:18:32+00:00 2026-05-15T03:18:32+00:00

I am a brand new programming student, so please forgive my ignorance. My assignment

  • 0

I am a brand new programming student, so please forgive my ignorance. My assignment states:

Write a 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.

Here is my code:

#include "stdafx.h"
#include <iostream>
using namespace std;

int main()
{
     const int NUM = 10;
     int values[NUM];
     int *p = &values[0];
     int x;
     for(x = 0; x < NUM; ++x, ++p)
     {
         cout << "Enter a value: ";
         cin >> *p;
     }  
     for(x = 0; x < NUM; ++x, ++p)
     {
         cout << *p << "  ";
     }
    return 0;
}

I think I know where my problem is. After my first loop, my pointer is at values[10], but I need to get it back to values[0] to display them. How can I do that?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T03:18:32+00:00Added an answer on May 15, 2026 at 3:18 am

    You can do exactly as you did first when you assigned p:

    p = &values[0];
    

    Besides, arrays are very much like pointers (that you can’t change) to statically allocated memory. Therefore, the expression &values[0] evaluates to the same thing that just values does. Consequently,

    p = &values[0];
    

    is the same as

    p = values;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm brand new to programming and Python and I'm trying my hardest to understand
Im brand new to Android Application development and I am working on an application
I'm brand new to Compact Framework and I need to compile a small project
I am brand new to LINQ and am trying to query my DataSet with
I have created a brand new WCF Service. I created this service by just
I have created a brand new heroku app, beforehand i deleted the old .git
I am brand new to AS3 and I am trying to move all of
I created a brand new WpfApplication, referenced netTiers classes, stuck a DataGrid on MainWindow,
I am programming a VST DSP plugin in c++. I am creating a series
I am applying an ADSR Envelope to fade in and out notes so I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.