below basic piece of code trying run
double h_a[9],h_b[2500],h_c[2704]; int r_a,c_a,r_b,c_b,r_c,c_c; r_a = c_a = 3; r_b = c_b = 50; r_c = r_a + r_b - 1; c_c = c_a + c_b - 1; for(int i=0;i<(r_a*c_a);i++) h_a = double(rand() % 50 + 1); for(i=0;i<(r_b*c_b);i++) h_b = rand() % 50 + 1; it showing me following errors: 1. incompatible types in assignment of 'double' 'double [9] 2. name lookup of 'i' changed iso 'for' scoping [-fpermissive]| 3. incompatible types in assignment of 'int' 'double [2500]'
help appreciated.
h_a , h_b arrays. can't assign value array, element of array.
replacing
h_a = double(rand() % 50 + 1); by
h_a[0] = double(rand() % 50 + 1); and making similar change in assignment h_b satisfy compiler. have no idea whether correct.
you have 2 for loops. first defines loop variable in loop header; second not:
for (int = blah; blah; blah) { ... } (i = blah; blah; blah) { ... } the scope of i defined in first loop loop. it's not visible in second loop. in old version of c++, scope extended block enclosing loop. under rules, have been legal. apparently compiler still recognizes old rules. change i = ... in second loop int = .... you'll have 2 distinct variables, both named i, 1 each loop.
Comments
Post a Comment