0

Odd number at odd index and even number at even index. in c++ using array

Can you pls solve this question?

24th Jul 2017, 12:36 PM
Nihal Srivastava
Nihal Srivastava - avatar
1 Odpowiedź
+ 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; }
24th Jul 2017, 12:58 PM
Hatsy Rei
Hatsy Rei - avatar