0
(C language) for loop doesn't work
this code should sum elements of 2D array put it doesn't give me the right answer =========================================== #include <stdio.h> main() { int total = 0; int k,i; int orders[5][2] = {{100,22},{220,33},{37,44},{16,55},{98,66}}; for (k = 0; k < 5; k++){ for(i=0;i<2;i++);{ total += orders[k][i]; } } printf("Total orders is %d\n", total); }
2 Answers
+ 8
Because you added semicolon after the inner for loop.
0
đ
Thanks