I want to create an array to store values from user input. The user input is in a while (choice=='y' || choice=='Y') loop. As long as the user keeps selecting Y/y at the end of the loop, they can enter more values and continue. I want to store the 2 values that are entered and a 3rd calculated value in an array. The user can stop after 1 value or keep going up to 100 iterations of the loop (if they so desire).
My original thought was to create 3 array variables but I am stuck trying to figure out the exact code needed to allow an array(s) to just grow, as needed. I do not want to preset the size of the array to any single value though. Any help in this manner would be appreciated.
3 2599
You can use some collection frameworks for this.
Regards
Dheeraj Joshi
Nepomuk 3,112
Recognized Expert Specialist
What you're doing sounds a lot like an ArrayList or a Vector, both of which are collections.
Greetings,
Nepomuk
Oralloy 988
Recognized Expert Contributor
I'd stick with the ArrayList, unless you require synchronization . But - I suspect that you aren't at the point of needing to know the difference in your training.
Work with what you've got, write a prototype, and if you have any questions about your code - ask them.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Christopher Benson-Manica |
last post by:
From FAQ 6.13:
int arr;
int (*a)=arr; /* legal, but useless */
printf( "%d\n", a ); /* error, bounds of a unspecified */
Are there non-contrived situations where an array of unspecified
bounds is useful?
|
by: Tee |
last post by:
Hi,
Anyone know how to redeclare an array with different size but keep the
previous data? Just like the redim preserve in VB.
Thanks.
|
by: redefined.horizons |
last post by:
I would like to have an array declaration where the size of the array
is dependent on a variable. Something like this:
/* Store the desired size of the array in a variable named
"array_size". */
unsigned short int array_size = 25;
/*Declare an array named "numbers" using the variable initialized
above. */
unsigned short int numbers;
|
by: foreverbored75 |
last post by:
Hello All!
I am just learning c++ in school and I have the following question:
Is there a way for the user to input the length of an array (console
application) without using another variable? I made this program that
finds the average of x number of numbers and stores the average in the
last index of the array of the numbers. The other other variable I have
is to determine the length of the array (totalNums). Is there a way to
get...
|
by: hn.ft.pris |
last post by:
Hi:
I have the following simple program:
#include<iostream>
using namespace std;
int main(int argc, char* argv){
const double L = 1.234;
const int T = static_cast<const int>(L);
int arr;
| |
by: Netaro |
last post by:
Hello!
So, i have this type of a problem -> i have wrote a function that sorts the array in ascending order. the beggining looks like this ->
template <typename T>
void PosortujBabelkowoTablice(T& Tablica, int i) {
// and the rest of a code....
So, as you see, i must always give the i param, which is the number of objects within array Tablica. But, i want to make it simpler, in a way i give only the array, without the quantity of the...
|
by: quiz123 |
last post by:
Hi folks,
I have a problem. my function call is
void Rotate_n(int array, int arraySize,int n);
//precondition: arraysize>=1 && n>=0 && n<=arraySize
//post condition: Values in the arrary are rotated forward(left to right)
by n positions.
eg: if the original array is {1,2,3,4,5}
then, rotate_n(array,5,1); will make it{5,1,2,3,4}
my problem is, how do i manipulate the array without using temp??
Can anyone give me a pointer as to how i...
|
by: subramanian100in |
last post by:
Is it possible to measure the size of an array without using the
sizeof operator ?
|
by: Pavan |
last post by:
Hi,
I need to create a consant array of larze size but however its
elements can be calculated using an equation, say for example I need
an int arry of 20 elements where each element will be
arr = 2 + (i*i)
But I want arry to be constant. How can I declare such a constant
array without actually defining all the elements?
|
by: Sunny |
last post by:
Hi, Can someone tell me, How to redefine array or make array empty or
null.
Here what I am trying to do.
var temp = new Array();
for(i=0; i <=outstring.length-1; i++) {
temp = outstring.split(',');
}
Once the for loop will finish doing it, I want temp array to be null
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |