Need C++ help with arrays.

Raj

Senior member
Aug 14, 2000
951
0
0
ok

accept 2 values from user
cin <<val1;
cin <<val2;

now this is what I have to do, how do I write the code for this
initialize all elements of the array using the following formula

a. i*i*val2 or (i*val1) whichever is lesser(i represents the index of the array element)



How do I do this?
 

bUnMaNGo

Senior member
Feb 9, 2000
964
0
0
it would seem pretty simple. just do an while loop, from i=0 to max array size-1, then do an if statement: if i*val1 > i*i*val2, array=i*i*val2... else array=i*val1. if i*i*val2==i*val1, then it wont matter which you use to set the value.