write a c program that will ask the user to enter 3 numbers thereafter, the program should display the smallest and the largest in terms of value of the numbers entered.
example output:
Enter First Number:10
Enter Second Number:15
Enter Third Number:13
LARGEST:15
SMALLEST:10
Please help me with this... all about c programming?
# include %26lt; stdio.h %26gt;
int main( void)
{
int input_values[3];
int max_value = 0;
int min value = 0;
int i=0;
memset(input_values, 0x00, sizeof(input_values));
for (i=0; i%26lt;3; i++)
{
if (i==0)
printf("Enter First Number: ");
else if (i==1)
printf("Enter Second Number: ");
else if (i==2)
printf("Enter Third Number: ");
scanf("%d",%26amp;input_values[i]);
}
max_value = min_value = input_values[0];
for (i=1; i%26lt;3; i++)
{
if (input_values[i] %26gt; max_value)
max_value = input_values[i];
if (input_values[i] %26lt; min_value)
min_value = input_values[i];
}
printf("LARGEST: %d \n", max_value);
printf("SMALLEST: %d \n", min_value);
return 0;
}
Reply:#include %26lt;stdio.h%26gt;
#define NUMBERS 3
int main(void)
{
int numbers[NUMBERS];
int HIGHEST;
int LOWEST;
int i;
for (i = 0; i %26lt; NUMBERS; i++)
{
printf("\nPlease enter a number: ");
scanf("%d", %26amp;numbers[i]);
}
LOWEST = HIGHEST = numbers[0];
for (i = 1; i %26lt; NUMBERS; i++)
{
if (numbers[i] %26lt; low)
LOWEST = numbers[i];
else if (numbers[i] %26gt; high)
HIGHEST = numbers[i];
}
printf("Lowest: %d \nHIGHEST: %d", LOWEST, HIGHEST);
return 0;
}
Reply:I believe someone has already asked this question today ( and I answered it) ...
Why don't you try searching for answers?
Reply:What code have you already written? I don't think that anyone will actually just give you the solution...
Reply:I just forwarded your question to your professor, you will get big ZERO for your project assignment. For getting homework help there are better websites like http://getafreelnacer.com/
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment