please help me how to get the highest and lowest number when I input 10 numbers..

the first run is:
Enter First Number:
Enter Second Number:
Enter Third Number:
Enter Fourth Number:
Enter Fifth Number:
Enter Sixth Number:
Enter Seventh Number:
Enter Eighth Number:
Enter Ninth Number:
Enter Tenth Number:

Upon Finishing Input of 10 Numbers this is the output:

The Highest Number is: (highest number)
The Lowest Number is: (lowest number)

help me code this help will be appreciated.. thanks.. help me pls.. ^_^

First of all, I would have 2 variables; first one for storing Min, and the second one for shoring Max. While you input a number, you compare with the Min and Max. If that number is smaller than Min, then assign it to Min. If it is bigger than Max, then assign it to Max.

what you could do is save each number into a file, then read that file line by line into a bubble sorter. Then when the program is done the first value in the file would be your highest number and the last number would be your lowest number.

Comments
Incredibly inefficient method for solving an excruciatingly simple problem

what you could do is save each number into a file, then read that file line by line into a bubble sorter. Then when the program is done the first value in the file would be your highest number and the last number would be your lowest number.

Why would you need to write it into file, when you can solve that problem without using saving into file.

i guess all you need is to place each input in an array and then do a bubble sort on that array, then output the first and last values.

i guess all you need is to place each input in an array and then do a bubble sort on that array, then output the first and last values.

Why don't you just compare it while you are inputting? Like this:

unsigned int n, min = 65535, max = 0, x;
// How many number do you want to input?
scanf("%d", &n);

for(int i = 0; i < n) {
  // Ask user to input their number
  printf("Please input your number: ");
  scanf("%d", &x);

  if (min > x) min = x;
  if (max < x) max = x;
}

// Out the final result
printf("Max:%d\nMin:%d", max, min);
#include<iostream.h>

int FindMax(int []);
int FindMin(int []);
int max;
int main()
{
int arraysize=10;
int num[arraysize];
cout<<

Edited 6 Years Ago by peter_budo: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks)

Comments
Didn't even post a complete program

i guess all you need is to place each input in an array and then do a bubble sort on that array, then output the first and last values.

There are two huge problems with your approach. First, your solution is doing way more than is necessary. If I was a professor giving this assignment, and you implemented your proposed solution, I would give you B even if the program worked flawlessly. You need to solve the problem without adding extra complexity. If all you need to do is find the min and max values, why would you sort?

Secondly, you are suggesting a bubble sort! Bubble sort is among the most inefficient of sorting methods. It's time complexity is O(n^2). Finding the max and min of a problem set is only O(n). So, basically, your solution would require however much time it would take to simply pass over the loop squared. That is a huge waste of time! Imagine you had a file with 1 billion integer entries. Do you really want to use a bubble sort on this list? Do you really want to save this list in memory?

I didn't mean to go on the offensive so much, but you need to understand the magnitude of such an error. Computer Scientists search for the simplest and most efficient correct solution. The solution you are suggesting is correct, in a way. However, it terribly inefficient and tremendously over complicated.

Comments
Find the maximum number of entries in the three-digit number, javacipt and html
This article has been dead for over six months. Start a new discussion instead.