Alphenex
Alphenex

Reputation: 27

Is there a way to put 2 variable in one variable? (it is kind of hard to explain)

For example:

int hello1;
int hello2;
int hello3;

for(int i = 1; i <= 3; i++)
{
    helloi = 99;
}

How can I do something similar like this but with it actually working... also, sorry if I'm being vague here.

Upvotes: 3

Views: 76

Answers (1)

Ken Wayne VanderLinde
Ken Wayne VanderLinde

Reputation: 19339

What you're looking for is an array:

int hello[3];

for (int i = 0; i < 3; ++i)
{
    hello[i] = 99;
}

Note that arrays use zero-based indexing, so the indices run from 0 to 2 rather than from 1 to 3.

Upvotes: 8

Related Questions