0
Odd number at odd index and even number at even index. in c++ using array
Can you pls solve this question?
1 Answer
+ 6
srand(time(0));
int array[10];
for (int i = 0; i < 10; i+=2)
{
array[i] = rand();
if (array[i] % 2 != 0) array[i] += 1;
array[i + 1] = rand();
if (array[i + 1] % 2 == 0) array[i + 1] += 1;
}