Securing Knowledge.
Continuosity on learning is the most important thing to secure your knowledge.
Wednesday, September 15, 2004
Exercise – repetitions (looping).
Question : Question -- Write a program that calculates and prints the average of several integers. Assume the last value read with scanf is the sentinel 9999. A typical input sequence might be :
(10 8 11 7 9 9999)
I succeed in answering it. Congrates carrotsusu!!! hehehe :p
#include stdio.h /* I’m not typing <> symbol cause its illegal in this blog*/
#include math.h /* I’m not typing <> symbol cause its illegal in this blog*/
int main ()
{
int x, y, jumlah, purata;
for ( x = 0; x <= 6; x++ )
{
scanf ("%d", &y);
if ( y == 9999) break;
jumlah = jumlah + y;
/*printf ("%d", x);*/
}
purata = jumlah / x;
printf ("\npurata keseluruhan nombor yang dimasukkan ialah: %d\n", purata);
return 0;
}
(10 8 11 7 9 9999)
I succeed in answering it. Congrates carrotsusu!!! hehehe :p
#include stdio.h /* I’m not typing <> symbol cause its illegal in this blog*/
#include math.h /* I’m not typing <> symbol cause its illegal in this blog*/
int main ()
{
int x, y, jumlah, purata;
for ( x = 0; x <= 6; x++ )
{
scanf ("%d", &y);
if ( y == 9999) break;
jumlah = jumlah + y;
/*printf ("%d", x);*/
}
purata = jumlah / x;
printf ("\npurata keseluruhan nombor yang dimasukkan ialah: %d\n", purata);
return 0;
}
carrotsusu, 9:02 PM