# Data Analysis Question

Page 1 of 1

## 13 Replies - 986 Views - Last Post: 12 November 2019 - 05:26 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'https://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=417421&amp;s=a20ab9950cf3e7057e00fa18680c859e&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 JR360

Reputation: 0
• Posts: 8
• Joined: 27-September 19

# Data Analysis Question

Posted 27 September 2019 - 06:38 PM

```#include <iostream>
#include <time.h>

using namespace std;

void choose(int a,int b,int c,int d[]);
void screen(int a[],int B)/>/>;

int main(){
int plays;
int numbers;
int price=plays*2;
int playerNumbers[]={};

choose(numbers,plays,price,playerNumbers);
screen(playerNumbers,plays);
}

void choose(int a,int b,int c,int d[]){
cout << "How many numbers? : ";
cin >> a;
cout << "How many plays? : ";
cin >> b;
cout << "That will cost " << c << endl;

for(int i=1;i<=5;i++){
cout << "Number" << i << ":";
cin >> d[i];
}
}

void screen(int a[],int B)/>/>{
for(int i=1;i<=5;i++){
cout << i;
for(int j=0;j<5;j++){
cout << "[" << a[j+1] << "]";
}
cout << endl;
}
}
```

My Question is how can i change the orders of the numbers in every line and how can i change the order from min to max. Simple lotto app for fun. in c++ code

This post has been edited by modi123_1: 27 September 2019 - 07:53 PM
Reason for edit:: In the future please use the [code] tag button in the editor

Is This A Good Question/Topic? 0

## Replies To: Data Analysis Question

### #2 modi123_1

• Suitor #2

Reputation: 15427
• Posts: 61,808
• Joined: 12-June 08

## Re: Data Analysis Question

Posted 27 September 2019 - 07:13 PM

Store them in a collection or array and sort.

### #3 JR360

Reputation: 0
• Posts: 8
• Joined: 27-September 19

## Re: Data Analysis Question

Posted 27 September 2019 - 07:43 PM

modi123_1, on 27 September 2019 - 07:13 PM, said:

Store them in a collection or array and sort.

What do you mean array and sort? So far I learn little about coding and is not easy, can you help me with this I just started a month ago.

### #4 modi123_1

• Suitor #2

Reputation: 15427
• Posts: 61,808
• Joined: 12-June 08

## Re: Data Analysis Question

Posted 27 September 2019 - 07:56 PM

I would suggest reading up on arrays then. The more direct route.

http://www.cplusplus...icles/NhA0RXSz/
https://www.dreaminc...al-1-using-sort

### #5 jimblumberg

Reputation: 5780
• Posts: 17,684
• Joined: 25-December 09

## Re: Data Analysis Question

Posted 28 September 2019 - 05:18 AM

By the way the following is illegal in C++: int playerNumbers[]={};.

First an array in C++ must have a size, you can not create an array without a size.

Second the size must be a compile time constant. You can not create statically allocated arrays with "runtime determined" sizes in C++. Example:

```int playersNumbers[100]; // Okay, size is a constant.

int arraySize = 100;
int playersNumbers[arraySize]; // Bad the size is not a compile time const.

const int arraySize 100;
int playersNumbers[arraySize]; Okay size is a compile time constant.

```

Jim

### #6 JR360

Reputation: 0
• Posts: 8
• Joined: 27-September 19

## Re: Data Analysis Question

Posted 17 October 2019 - 05:48 PM

Jim Blumberg, hi there you answer my question with this, but I still don't understand to apply the array size. it's possible for you to take a look at this code, please.
```#include <iostream>
#include <time.h>

using namespace std;

void choose(int a,int b,int c,int d[]);
void screen(int a[],int B)/>/>/>/>;

int main(){
int plays;
int numbers;
int price=plays*2;

choose(numbers,plays,price,playerNumbers);
screen(playerNumbers,plays);
}

void choose(int a,int b,int c,int d[]){
cout << "How many numbers? : ";
cin >> a;
cout << "How many plays? : ";
cin >> b;
cout << "That will cost " << c << endl;

for(int i=1;i<=5;i++){
cout << "Number" << i << ":";
cin >> d[i];
}
}

void screen(int a[],int B)/>/>/>/>{
for(int i=1;i<=5;i++){
cout << i;
for(int j=0;j<5;j++){
cout << "[" << a[j+1] << "]";
}
cout << endl;
}
}

```

This post has been edited by Skydiver: 17 October 2019 - 06:18 PM
Reason for edit:: Removed unnecessary quote. Put code in code tags. Learn to do this yourself.

### #7 Skydiver

• Code herder

Reputation: 7187
• Posts: 24,357
• Joined: 05-May 12

## Re: Data Analysis Question

Posted 17 October 2019 - 06:19 PM

There is no need to quote the post above yours. Just use the big Reply button or the Fast Reply area. Also, please learn how to use code tags. It shows you right in the watermark how to do this.

### #8 JR360

Reputation: 0
• Posts: 8
• Joined: 27-September 19

## Re: Data Analysis Question

Posted 17 October 2019 - 06:25 PM

Skydiver, on 17 October 2019 - 06:19 PM, said:

There is no need to quote the post above yours. Just use the big Reply button or the Fast Reply area. Also, please learn how to use code tags. It shows you right in the watermark how to do this.

ahh thank you for the information im new using this website. in relation to my question is there any place where I can learn more about what I want to do with this code. your help will highly be appreciated.

### #9 Skydiver

• Code herder

Reputation: 7187
• Posts: 24,357
• Joined: 05-May 12

## Re: Data Analysis Question

Posted 17 October 2019 - 06:57 PM

I find it highly insulting that I just told you that there is no need to quote the post above yours, and told you how to avoid quoting, yet you just ignored that. So what use would be if I told you where you can learn more? Would you also ignore that?

Good luck with your quest to learn. I'm out.

### #10 JR360

Reputation: 0
• Posts: 8
• Joined: 27-September 19

## Re: Data Analysis Question

Posted 17 October 2019 - 07:33 PM

skydiver, im so sorry I did not mean to write that, im new to this language and coding. I apologize if I was rude to you skydiver... I do want help with this code, please.

### #11 JR360

Reputation: 0
• Posts: 8
• Joined: 27-September 19

## Re: Data Analysis Question

Posted 29 October 2019 - 03:09 PM

First, thank you for helping me with this code problem. the problem that I'm having with this code is that is not changing the numbers that have been chosen. this code what is doing is allowing you to choose a group of numbers and then mix them in different orders. so far no errors have appeared the problem is that I don't know how to mix the numbers in different order, I research a couple of things on C++ and, I found that you can put them in collection or array and sort then, but so far I have not learned how to use algorithm or collection of array and sort. so far I have not been able to figure it out it's so frustrating not being able to figure out.

okay this is an example of what I want to look like
EXAMPLE:
4, 10, 11, 15, 17
4 ,10, 11, 28, 53
4, 10, 15, 38, 53
4, 10, 19, 27, 49
4, 10, 28, 56, 57
4, 10, 32, 56, 57
4, 15, 19, 27, 49
11, 15, 19, 27, 59
11, 15, 28, 32, 53

So far this is what I have

```#include <iostream>
#include <time.h>

using namespace std;

void choose(int a,int b,int c,int d[]);
void screen(int a[],int B)/>;

int main(){
int plays;
int numbers;
int price=plays*2;

choose(numbers,plays,price,playerNumbers);
screen(playerNumbers,plays);
}

void choose(int a,int b,int c,int d[]){
cout << "How many numbers? : ";
cin >> a;
cout << "How many plays? : ";
cin >> b;
cout << "That will cost " << c << endl;

for(int i=1;i<=5;i++){
cout << "Number" << i << ":";
cin >> d[i];
}
}

void screen(int a[],int B)/>{
for(int i=1;i<=5;i++){
cout << i;
for(int j=0;j<5;j++){
cout << "[" << a[j+1] << "]";
}
cout << endl;
}
}

```

### #12 Salem_c

• void main'ers are DOOMED

Reputation: 2408
• Posts: 4,542
• Joined: 30-May 10

## Re: Data Analysis Question

Posted 29 October 2019 - 11:20 PM

Is your example the input or the output?

You need better variable names than a,b,c,d if you want to understand things.

If you want a function to change a value in another function, then you need to use references.
```void getPlayInfo(int &howmany, int &numplays ) {
cout << "How many numbers? : ";
cin >> howmany;
cout << "How many plays? : ";
cin >> numplays;
}
int main ( ) {
int howmany, numplays;
getPlayInfo(howmany,numplays);
cout << howmany << "," << numplays << endl;
}

```

### #13 Skydiver

• Code herder

Reputation: 7187
• Posts: 24,357
• Joined: 05-May 12

## Re: Data Analysis Question

Posted 30 October 2019 - 05:15 AM

### #14 JR360

Reputation: 0
• Posts: 8
• Joined: 27-September 19

## Re: Data Analysis Question

Posted 12 November 2019 - 05:26 PM

Salem_c, on 29 October 2019 - 11:20 PM, said:

Is your example the input or the output?

You need better variable names than a,b,c,d if you want to understand things.

If you want a function to change a value in another function, then you need to use references.
```void getPlayInfo(int &howmany, int &numplays ) {
cout << "How many numbers? : ";
cin >> howmany;
cout << "How many plays? : ";
cin >> numplays;
}
int main ( ) {
int howmany, numplays;
getPlayInfo(howmany,numplays);
cout << howmany << "," << numplays << endl;
}

```

Hi, Salem_c can you use my code and change what you are talking about. I'm new to coding and I have no idea what you are saying about references, I will appreciate, please. also how did you learn about coding
```#include <iostream>
#include <time.h>

using namespace std;

void choose(int a,int b,int c,int d[]);
void screen(int a[],int B)/>;

int main(){
int plays;
int numbers;
int price=plays*2;

choose(numbers,plays,price,playerNumbers);
screen(playerNumbers,plays);
}

void choose(int a,int b,int c,int d[]){
cout << "How many numbers? : ";
cin >> a;
cout << "How many plays? : ";
cin >> b;
cout << "That will cost " << c << endl;

for(int i=1;i<=5;i++){
cout << "Number" << i << ":";
cin >> d[i];
}
}

void screen(int a[],int B)/>{
for(int i=1;i<=5;i++){
cout << i;
for(int j=0;j<5;j++){
cout << "[" << a[j+1] << "]";
}
cout << endl;
}
}

```