I have to do this:
Make a program that loads a 12x4 array with the values of the store, where each row represents one month of the year and each row column represents a week of the month. Calculate and show;
the total sold in each month of the year, showing the month's name in full;
the total sold every week throughout the year;
The total sold by the store in the year.
The total of the year worked out, but the other two results can not, the numbers do not appear right. I really do not know how to proceed: (
This is my code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <conio.h>
#include <time.h>
#include <locale.h>
int main ()
{
setlocale(LC_ALL, "PORTUGUESE");
int mat[12][4], l, c, totalsemana, totalano, jan, fev, mar, abr, mai, jun, jul, ago, set, out, nov, dez;
char mes;
//PEDIR VALORES
for(l=0; l<12; l++)
{
for(c=0; c<4; c++)
{
printf("\n________________________________________________________________");
printf("\n\n Insira o valor das vendas do mês %i - semana %i - posição [%i][%i]: ", l+1, c+1, l+1, c+1);
scanf("%i", &mat[l][c]);
totalano = totalano + mat[l][c];
}
}
for(l=0; l<12; l++)
{
for(c=0; c<4; c++)
{
jan = jan + mat[1][c];
fev = fev + mat[2][c];
mar = mar + mat[3][c];
abr = abr + mat[4][c];
mai = mai + mat[5][c];
jun = jun + mat[6][c];
jul = jul + mat[7][c];
ago = ago + mat[8][c];
set = set + mat[9][c];
out = out + mat[10][c];
nov = nov + mat[11][c];
dez = dez + mat[12][c];
}
}
printf("\n\n ################### R E S U L T A D O S #####################");
printf("\n\n ****************************************************");
printf("\n\n O total vendido no ANO é: %i", totalano);
//MOSTRAR EM CADA SEMANA
printf("\n\n ****************************************************");
printf("\n\n O total vendido em cada SEMANA é: ");
for(c=0; c<4; c++)
{
for(l=0; l<12; l++)
{
printf("\n------------------------------------");
printf("\n Mês %i - semana %i: ", l+1, c+1);
printf("%i", mat[l][4]);
}
}
printf("\n\n ****************************************************");
//MOSTRAR CADA MES
printf("\n\n O total de venda em cada MÊS no ano é: ");
printf("\n Janeiro: %i", jan);
printf("\n Fevereiro: %i", fev);
printf("\n Março: %i", mar);
printf("\n Abril: %i", abr);
printf("\n Maio: %i", mai);
printf("\n Junho: %i", jun);
printf("\n Julho: %i", jul);
printf("\n Agosto: %i", ago);
printf("\n Setembro: %i", set);
printf("\n Outubro: %i", out);
printf("\n Novembro: %i", nov);
printf("\n Dezembro: %i", dez);
printf("\n\n ****************************************************");
}