This program is supposed to prompt the user to enter the age of the youngest family member and ask the user if there are any more family members. after that it tells the user to enter the age of the next youngest family member and then asks again if there are any more family members. If the answer is yes, the user is prompted to enter the next youngest family members age. this continues till the user hits N for no, at which point the message"Thank you...." is printed , followed by the ages(the user entered) in reverse order. What I am doing wrong? Is it the specifying of the size of the array? I thought all arays types must have a size indicated.
Your help would be much appreciated. I will later add an ERROR message for a non-int value and exit the code and if the input is a valid int but outside of say 150 yrs(1<=ageValue&&ageValue<=150)an ERROR message shd be displayed and the user reprompted. Appropriate error messages as well as help with coding would be greatly appreciated.
2006-07-23
08:28:01
·
5 answers
·
asked by
jdegbor
1
in
Computers & Internet
➔ Programming & Design
g1<=ageValue&&ageValue<=150)
2006-07-23
08:28:10 ·
update #1
// reading values printing out input in reverse
//**********************************************************************
#include
using namespace std;
int main()
{
int ageValue[10];
int count=0;
char choice;
cout<<"Enter the age of the youngest family member:"<
cin>>ageValue[count];
cout<<"Are there any more family members?(Y for yes and N for no)"<
cin>>choice;
for(count=1; choice=='Y'||choice=='y'; count++)
{
cout<<"Enter the age of the next youngest person"<
cin>>ageValue[count];
cout<<"Are there any more family members?(Y for yes and N for no)";
cin>>choice;
}
cout<<"Thank you. The ages of your family in reverse order are:";
for(count=0; count<10; count--)
cout<
return 0;
}
2006-07-23
08:28:33 ·
update #2
The thing is that I only specified 10 because i thought all arrays should have a size. In this instance I thought it would limit the number of re-prompts the user gets to 10 times. My undersatnding of this topic is limited.. Ideally I would like the user to be reprompted for the age of the next youngest(endless loop) till the user hits N. How do you define an array in that case?(no constant value..just a variable) I would be grateful to see your suggestions and the re-coding you think would work. Thanks!
2006-07-23
08:44:33 ·
update #3