need help...

i already doing some program, but when i want to compile=ok, but after key in the result, no ouptut average..the cmd just gone...it cannot be done... anyone can help me why..i still new in c++ langunage...

#include <stdio.h>
#include <conio.h>


void main()
{
int BacaanAPIMingguan[4][7];
int JumlahAPIMingguan[4];
int pembilang1, pembilang2;

for(pembilang1 = 0; pembilang1 < 4; pembilang1++)
{
for(pembilang2 = 0; pembilang2 < 7; pembilang2++)
BacaanAPIMingguan[pembilang1][pembilang2] = 0;
}

//initialize PurataAPIBMingguan and JumlahAPIMingguan to 0
for (pembilang1 = 0; pembilang1 < 4; pembilang1++)
{
BacaanAPIMingguan[pembilang1] == 0;
JumlahAPIMingguan[pembilang1] == 0;
}

for (pembilang1 = 0; pembilang1 < 4; pembilang1++)
{
JumlahAPIMingguan[pembilang1] = 0;
printf("Bacaan API Minggu[ %d ]:\n",pembilang1+1);
for (pembilang2 = 0; pembilang2 < 7; pembilang2++)
{
switch(pembilang2)
{
case 0 : printf("\t Isnin : "); break;
case 1 : printf("\t Selasa: "); break;
case 2 : printf("\t Rabu : "); break;
case 3 : printf("\t Khamis: "); break;
case 4 : printf("\t Jumaat: "); break;
case 5 : printf("\t Sabtu : "); break;
case 6 : printf("\t Ahad : ");
}

scanf("%d",&BacaanAPIMingguan[pembilang1][pembilang2]);

JumlahAPIMingguan[pembilang1] += BacaanAPIMingguan[pembilang1][pembilang2];
}
}

printf("\n\n\n\n\t\tIsnin\tSelasa\tRabu\tKhamis\tJumaat\tSabtu\tAhad\tPurata");

for (pembilang1 = 0; pembilang1 < 4; pembilang1++)
{
switch(pembilang1)
{
case 0 : printf("\nMinggu 1 :\t"); break;
case 1 : printf("\nMinggu 2 :\t"); break;
case 2 : printf("\nMinggu 3 :\t"); break;
case 3 : printf("\nMinggu 4 :\t"); break;
}

for (pembilang2 = 0; pembilang2 < 7; pembilang2++)
{
printf(" %d \t",BacaanAPIMingguan[pembilang1][pembilang2]);
}
printf(" %d \n",JumlahAPIMingguan[pembilang1]/7); //purata setiap minggu

}

}

It cannot give the result...
Last edited on
1
2
		BacaanAPIMingguan[pembilang1] == 0;
		JumlahAPIMingguan[pembilang1] == 0;

For starters, these should not be "==".

in fact your variable "pembilang1" is 4, so your for loop:
for (pembilang1 = 0; pembilang1 < 4; pembilang1++)
will not run.
what are you trying to do?
Last edited on
By using two-dimensional arrays, how i must write a program to read this Air Pollution Index (API) as an input from the user and store the data in a two-dimensional array. and this program should calculate the average API for each of the four weeks. The example of API readings are given in the table below.

Mon Tue Wed Thus Fri Sat Sun Average
Week 1 88 43 56 78 98 102 105 ??
Week 2 101 110 115 130 78 77 56 ??
Week 3 44 67 89 45 33 45 33 ??
Week 4 100 189 201 55 34 67 88 ??

the question is like that... already finish write code but after all input is key in.. the results not show...it's gone... actually, after i key in all the data sheet.. the average result will appear..but when i run the program.. all data can fill the after finish key in data.. they no output show...
Topic archived. No new replies allowed.