I get weird decimal digits when I run the program below.
int coe_amount;
cout << "How many coefficients exist in your term? ";
cin >> coe_amount;
float coefficient[coe_amount];
for (int count = 0; count < coe_amount; count ++)
{
cout << "Enter the coefficients of your variables, for term " << count << ": ";
cin >> coefficient[count];
}
for (int count = 0; count < coe_amount; count ++)
{
cout << coefficient[count+1];
cout << coefficient[ count];
}
It might have something to do with coefficient[count+1], which I don't know if it is a legal statement.
Basically I want the "coefficient[count+1]" to print the list of array elements that is one subscript ahead of coefficient[ count], for
"count < coe_amount" times. Is this how you do it? If not can somehow show me the correct syntax?
Not really, no. Variables are supposed to have their size fixed at compile-time, not runtime. I've had to fix lots of code where people have done things like that. It happened to work for them by sheer coincidence but compile it on a different system and it crashes.
If you tell a C compiler to do something crazy, it will do so, and not always complain, but might not do what you actually wanted. Don't trust that code is "right" just because it "works".