# Answer to Question #41634 in C++ for Vergil

Question #41634

Hi experts :

i have a question that i hope to find an answer here

whats the fast way to assign values to array with a elements less than 20

direct assignment or using loop

is this better :

float arr[20] ;

arr[0] = 0 ; array[1] = 1 ; arr [2] = 2;.....;arr[19]=3;

or this way :

for (int i = 0 ; i < 20 ;++i)

arr[i] = i;

thank to you in advance

i have a question that i hope to find an answer here

whats the fast way to assign values to array with a elements less than 20

direct assignment or using loop

is this better :

float arr[20] ;

arr[0] = 0 ; array[1] = 1 ; arr [2] = 2;.....;arr[19]=3;

or this way :

for (int i = 0 ; i < 20 ;++i)

arr[i] = i;

thank to you in advance

Expert's answer

Dear visitor,

The loop way is much more easy to understand and to write than the first one,

But technically both of them are doing the same thing with the same speed.

The loop way is much more easy to understand and to write than the first one,

But technically both of them are doing the same thing with the same speed.

Need a fast expert's response?

Submit orderand get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

## Comments

## Leave a comment