![]() |
input data from user into array
How do I ask the user to input some data, and put it into different parts of an array?
Today, I have an assignment that requires me to have the user enter a digit, then ask if they want to do it again, and then find the average of the numbers entered. I have to do this using an array of up to 15 numbers. |
Use a loop?
'Cos it's an assignment, I'm not going to give you the code. I'll explain what I'd do though: loop through fifteen times, asking the user for input. If at any point the user decides he doesn't want to continue, simply break out of the loop. To put data in a specific part of an array: :
for (int i = 0; i < ARRAY_SIZE; i++) |
here's what I have thus far. the problem im having now is with the do-while loop:
:
#include "conio.h" |
Brace mismatch, helps when you indent like:
:
#include <iostream> |
thanks for the help! i got it
|
Just some additional blather, along the lines of one of Ruben's discoveries. You should probably, while a novice, line your braces up. It's a stylistic issue, true, but a visual aid helps. You should probably use them even for single-line blocks for a while. You should definitely indent so the nesting is obvious. An editor that can indicate matching braces is nice, also.
|
| All times are GMT -5. The time now is 7:51 AM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC