invalid operands of typs ‘double’ & ‘int’ to binary ‘operator%’

why do i get this error:
invalid operands of typs ‘double’ & ‘int’ to binary ‘operator%’

:Btw im trying to generate a 10 element vector such each element is randomly generated that falls within the range of [0.1,1.0]

below is my code:
1
2
3
4
5
vector<double> B(10);
srand(time(0));
for (int j=0;j<10;j++){
    B[j]=0.1*rand()%10;
    cout<<B[j];}
Order of evaluation. 0.1 * rand() % 10 is same as (0.1 * rand()) % 10. You want modulo first and multiplication later.

Reread http://www.cplusplus.com/reference/cstdlib/rand/
(You won't get [0.1,1.0] with your current equation.)
Topic archived. No new replies allowed.