Problem with float and array

0

I have to add the values that have two or more decimal places but when I put it on exp: "1.0", it fills the whole row automatically and jumps to the next, I reviewed and I do not know why it is giving error so thank you if you can help.

#include <stdio.h>
#include <stdlib.h>
#include <locale.h>

int main () { setlocale(LC_ALL,"Portuguese");

    float matriz[7][4], soma = 0;

    for ( int i = 0; i < 7; i++){

        for ( int h = 0; h < 4; h++){
            printf("\nInforme o valor da linha %i e coluna %i: ",i,h);
            scanf("%f",&matriz[i][h]);
        }

        system ("cls");

    }

    for (int c = 0; c < 7; c++){
        for ( int k = 0; k < 4; k++){
            soma += matriz[c][k];
        }
    }

    printf("\nO valor é: %.0f\n",soma);

    return 0;
}
    
asked by anonymous 29.09.2016 / 23:06

1 answer

3

You have specified the locale of the program as Portuguese (called setlocale on the first line). You need to enter the number in this format - if you enter 1,2 instead of 1.2 your program should do what you want.

    
30.09.2016 / 07:14