Securing Knowledge.
Continuosity on learning is the most important thing to secure your knowledge.
Wednesday, September 15, 2004
The if/else selection structure
I think there’s a better way to write the code below. Sorry, I forgot where’s the question is…
#include stdio.h /* I’m not typing <> symbol cause its illegal in this blog*/
int main ()
{
int x, y, z, sum, avg, product;
printf ("Masukkan 3 integer : ");
scanf ("%d%d%d", &x, &y, &z);
sum = x+y+z;
printf ("Sum is : %d\n", sum);
avg = sum/3;
printf ("Avg is : %d\n", avg);
product = x*y*z;
printf ("Product is : %d\n", product);
if (x > y)
if (x > z)
printf ("Largest : %d\n", x);
if (y > x)
if (y > z)
printf ("Largest : %d\n", y);
if (z > x)
if (z > y)
printf ("Largest : %d\n", z);
if (x <>
if (x <>
printf ("Smallest : %d\n", x);
if (y <>
if (y <>
printf ("Smallest: %d\n", y);
if (z <>
if (z <>
printf ("Smallest : %d\n", z);
return 0;
}
#include stdio.h /* I’m not typing <> symbol cause its illegal in this blog*/
int main ()
{
int x, y, z, sum, avg, product;
printf ("Masukkan 3 integer : ");
scanf ("%d%d%d", &x, &y, &z);
sum = x+y+z;
printf ("Sum is : %d\n", sum);
avg = sum/3;
printf ("Avg is : %d\n", avg);
product = x*y*z;
printf ("Product is : %d\n", product);
if (x > y)
if (x > z)
printf ("Largest : %d\n", x);
if (y > x)
if (y > z)
printf ("Largest : %d\n", y);
if (z > x)
if (z > y)
printf ("Largest : %d\n", z);
if (x <>
if (x <>
printf ("Smallest : %d\n", x);
if (y <>
if (y <>
printf ("Smallest: %d\n", y);
if (z <>
if (z <>
printf ("Smallest : %d\n", z);
return 0;
}
carrotsusu, 9:27 PM