/this is trying to store user input into the 51st element
//You can only use myarray[0]...myarray[49] (= 50 doubles).
cin >>myarray[50]
So for this part your saying each time I ask the user to input a Temperature, I have to put a cin statement for myarray[0], myarray[1], myarray[2] etc etc going up one each time until I reach 49? Is there any way to automatically put the user data into the array and tell it to go to the next one without inputing a number into [ ] ?
You'd use a for loop . . .
>> ;cout << " Enter 1 to input more values, 0 to stop";
in this line i got an error originally without the ; at the beginning, and visual studio c++ told me to enter it for some reason, it has done this a few times I think it is because i had the wrong type of brackets.
Look at your code.
Code:
cin >>myarray[50]
;cout << " Enter 1 to input more values, 0 to stop";
It would be more readable as
Code:
cin >>myarray[50];
cout << " Enter 1 to input more values, 0 to stop";
The missing semicolon errors are misleading, they always point to the following line (where the missing semicolon was detected).
>> Do you know how to use a for loop? It's basically the same idea here. Loop from index = 0 and while index is less than 50, incrementing index each time. If the user enters 0 to stop, then break out of the loop.
I think I know how to set up a for loop for this array, and to have the user enter 0 to finish. My problems run into entering the value of what the user inputs into my array which is assumed to be no more than 50, and have them choose to enter 0 or 1 to continue and have it restart in the same loop. Then when they do choose to stop the loop it should print out not the value of the myarray[number] , but the number of actual arrays created by the user. Any help greatly appreciated thanks, im on a different computer atm or I would send my updated code.
Something like this should work:
Code:
do {
get_a_number();
} while(the_number is invalid);
[edit] Sorry, I read the requirements as "the numbers entered must be less than 50", not "there must be less than 50 numbers entered." Ignore the last part of this post. See Daved's post below. [/edit]