View Full Version : help on array
reefjames
12-15-03, 12:08 AM
How do I make a program which would look like this
YEAR: "user input"
JAN : "user input"
FEB : "user input"
MAR : "user input"
.
.
.
DEC: "user input"
And make a bar graph out of it?
thanks in advance!~
albmons
12-31-03, 12:08 AM
How do I make a program which would look like this
YEAR: "user input"
JAN : "user input"
FEB : "user input"
MAR : "user input"
.
.
.
DEC: "user input"
And make a bar graph out of it?
thanks in advance!~
What you are asking seems vague,
But, I'd guess a one dimensional array would work.
int array(13) = 0;
The above declares and intializes it to zero.
How about something like this:
int month(13) = 0;
cout<<"Jan:"; cin>>month[1];
cout<<"Feb:"; cin>>month[2];
cout<<"Mar:"; cin>>month[3];
cout<<"Apr:"; cin>>month[4];
cout<<"May:"; cin>>month[5];
cout<<"Jun:"; cin>>month[6];
cout<<"Jul:"; cin>>month[7];
cout<<"Aug:"; cin>>month[8];
cout<<"Sep:"; cin>>month[9];
cout<<"Oct:"; cin>>month[10];
cout<<"Nov:"; cin>>month[11];
cout<<"Dec:"; cin>>month[12];
cout<<"\n\n Bellow Are the results: \n\n";
for (int j=1; j<=12; j++)
{
for (int i=1; i<=month[j]; i++)
{
echo "*";
}
echo "\n";
}
of course you would have to include the "<iostream.h>" library and put the whole thing in the main(){ // stuff here } function, then compile it.
I don't know if this answers your question or not. Does it?
How do I make a program which would look like this
YEAR: "user input"
JAN : "user input"
FEB : "user input"
MAR : "user input"
.
.
.
DEC: "user input"
And make a bar graph out of it?
thanks in advance!~
tu_user
01-26-04, 12:06 AM
Ask us not to help u in ur home work. Just try ur best and then send us the code, if there is anything to help sure we'll help u. Y? r we here. Try the above mentioned code by digioz.
vBulletin® v3.6.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.