Small program

How would i create a small little program like this.

Enter a value N == > 3

your numbers are ==> 1 2 3

would you like to go again ? y/n == > Y

Enter a value N == > 6

your numbers are == > 1 2 3 4 5 6

would you like to go again? Y/N == > N


I'm very confused if i should use an array or just a sequence of numbers that add up by 1. I know how to the user loop though.
Can you write a loop where loop counter starts from 1, ends after N, and increases by one on each iteration?
you should use a loop (iterative control structure) for this problem, and this loop should be internal to the user loop itself
this is what I have so far.

// final.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>
#include <ctime>

using namespace std;

const unsigned int Array = 10;
// ==============================
int main() {

char GoAgain;
int C[Array];
int ii = 0;
do {
int A;
cout << "Enter a value ==> ";
cin >> A;

for (ii = 0; ii < Array; ii++) {
cout << "Your numbers are == > " << C[A] << endl;
}
for (ii = 0; ii = Array; ii++) {
cout << endl;
}






cout << "Hey Buddy! Want to go again? " << endl;
cin >> GoAgain;
} while (GoAgain == 'y' || GoAgain == 'Y');


return 0;


}//Function main()




I want the program to output what I wrote atth e beginning of the this topic
You need to allocate the array dynamically since it's size could change at every selection. Something along these lines:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include <iostream>
#include <string>

using namespace std;

int main()
{
    bool Quit = false;

    while(!Quit)
    {
        cout << "Enter a value ==> ";
        int SIZE;
        cin >> SIZE;

        int * C = new int[SIZE];

        cout << "Your numbers are: ";
        for (int i = 0; i < SIZE; i++)
        {
            C[i] = i + 1;
            cout << C[i] << " ";
        }
        cout << "\nHey Buddy! Want to go again? (Y/N)" << '\n';
        string GoAgain;
        cin >> GoAgain;
        if((GoAgain == "N")||(GoAgain == "n"))
       {
           Quit = true;
       }
       delete C;
    }
}









No. There is no need for any array. Even the homework instructions that he posted say so:
you should use a loop
int C[Array];

this looks like an array, no? maybe OP should clarify ..
Topic archived. No new replies allowed.