PLEASE HELP!! histogram coding problem

Hi!,
So I have a hw problem where i need to make a histogram that will graph up to 5 numbers all within the range of 5-25. The code needs to have a check that will stop it from graphing any numbers lower than 5 and higher than 25 and another check for the amount of numbers being inputted. The checks are basically what I need help with, I tried to use an if statement to limit it but it did not work. Im a beginner and any advice is much appreciated.

this is what I have so far
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
  #include <iostream>
#include <iomanip>
using namespace std;

int main(){

const int arraySize = 5;
int array[arraySize] = {0};
    

cout<<"Enter up to 5 numbers in the range of 5-25"<<endl;
for(int a=0; a<arraySize; a++)
{
	if(a <=25)
	cout <<"Enter a number please."<<endl;
	else
	cout <<"Enter another number please."<<endl;
	cin >> array[a];
}

cout<<setw(25)<<"Histogram"<<endl;
        
for(int i = 0; i < arraySize; i++)
{            
	for(int j = 0; j < array[i]; j++)
	cout <<"*";
	        
	cout<<endl;
	}
return 0;	
}
Last edited on
Topic archived. No new replies allowed.