Please check the program: In [10] [10] Calculate the sum of the positive elements of the matrix above the main diagonal. B - real numbers

#include <stdio.h> #include <conio.h> #include <math.h> int main() { float i,j,B[10][10],s; s=0; printf("vv elementy matritsy B:\n"); for (i=0;i<10;i++) for (j=0;j<10;j++) scanf("%d",&B[i][j]); printf("martitsa B:\n"); for (i=0;i<10;i++) { for (j=0;j<10;j++) printf("%d\t",B[i][j]); printf("\n");} for (i=0;i<10;i++) { for (j=0;j<10;j++) if(i<j) s=s+B[i][j]; } printf("s=%d",s); getch(); } 
  • 2
    For a start: where is the test for the positivity of the matrix element? - skegg

1 answer 1

Checked, ok. Only printf ("s =% d", s); need to be replaced, for example, by

 printf("s=%g",double(s)); 
  • one
    @ Michael M, badly checked. In the last 2 nested cycles, at least one tragic mistake and one inaccuracy - BuilderC
  • please tell me what the error is - wladen39
  • one
    Alas me! Indeed, there is no positive verification - Mikhail M