Thelis
Golden Master
- Messages
- 5,410
So, I had to write a program that finds out the minimum of three numbers using arrays... Well, I didn't feel like arraying, so I found a way around it.
Code:
#include <stdio.h>
/*Yo, what be up in da professor hizzou!?*/
main (void)
{
int n1, n2, min12, n3;
printf ("Enter the first number:");
scanf ("%d", &n1);
printf ("Enter the second number:");
scanf ("%d", &n2);
printf ("Enter the third number:");
scanf ("%d", &n3);
if (n1==n2 and n1==n3) printf ("The numbers are the same.");
else if (n1<=n2 && n1<=n3) printf ("The minimum number between %d, %d and %d is %d.", n1, n2, n3, n1);
else if (n1==n2 and n1<n3) printf ("The minimum number between %d, %d and %d is %d.", n1, n2, n3, n1);
else if (n1==n2 and n1>n3) printf ("The minimum number between %d, %d and %d is %d.", n1, n2, n3, n3);
else if (n2<=n1 && n2<=n3) printf ("The minimum number between %d, %d and %d is %d.", n1, n2, n3, n2);
else if (n3<=n1 && n3<=n2) printf ("The minimum number between %d, %d and %d is %d.", n1, n2, n3, n3);
else if (n1==n2 and n1<n3) printf ("The minimum number between %d, %d and %d is %d.", n1, n2, n3, n1);
}