reads ten numbers and prints the largest and smallest numbers entered.



#include <iostream>

using namespace std;

int main() {
int count;
double num;
cout<<"please enter ten numbers ";

count = 10;

while(count<num)
{
cout<<count<<"";
count++;

}


return 0;
}
anyone who know
First get the input from the user. Then compare each value to get the highest/lowest.
Improvable but simple version.


//compile with g++
#include <iostream>

using namespace std;

int main ()
{
int count;
double array[10], max,min;

cout << "please enter ten numbers " << flush;
for(count = 0; count < 10; count++)
cin >> array[count];

max = min = array[0];
for(count = 1; count < 10; count++)
{
if(max < array[count])
max = array[count];
if(min > array[count])
min = array[count];
}


cout << "Greatest was: " << max
<< "\nSmallest was: " << min
<< endl;
return 0;
}
Improvable but simple version. (Requires you have the WANOP.h file installed properly, you can find it here: http://www.cplusplus.com/forum/lounge/33512/#msg181953 )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include "WANOP.h"

PROGRAM("417");
double s(0);
double b(0);
double i(0);
unsigned u(0);
void bob(void){if(u++>9){go=0;std::cout<<"Smallest:"<<s<<std::endl<<"Biggest:"<<b<<std::endl;}else std::cin >> i;}
void lol(void){s=(s>i)?i:s;}
void mom(void){b=(b<i)?i:b;}
START_ADD_FUNCTIONS
ADD(bob);
ADD(lol);
ADD(mom);
END_ADD_FUNCTIONS
Topic archived. No new replies allowed.