## lou38

I need help with this assignment, I dont know where to start. Here is what the assignment is:
Write a program that finds both the largest and smallest of several integers. Assume that the first integer read specifies the number of values remaining to be entered and that the first number is not one of the integers to compare. Your program should read only one value per input statement. For example, an input sequence might be

6 20 30 40 50 60 70

where the 6 indicates that the subsequent 6 values are to be compared.

``````//Assign2: assign2_00.cpp
// project finds the largest and smallest numbers of 6 integers
#include <iostream>
using namespace std;

int main()
{
int counter = 1;
int number;

while (counter<=6)
{
cout<<"Enter number:  "<<endl;
counter++;
cin>>number;
}
{
if (number>=70)
cout<<"largest number is:  "<<number<<endl;

if (number <=20)
cout<<"smallest number is:  "<<number<<endl;
}

}
``````

## chief427 -3

``````// NOTE: No error checking on input values
//

#include<iostream>
// use limits.h to get minimum and maximum values
#include "limits.h"

using namespace std;

int main(int argc, char* argv[])
{
int iCount = 0;
// set up initial comparison values
int iMax = INT_MIN;  // ALMOST guaranteed to be bigger than this
int iMin = INT_MAX;  // ALMOST guaranteed to be smaller than this
// get the count of how many we should be comparing

cout << "Enter the number of integers to read and compare "<< endl;
cin >> iCount;
if (iCount > 0) {
// allocate an array to hold the values
int *values = new int[iCount];
if (values != NULL) {
for (int index = 0; index < iCount; index++) {
cout << "Enter Value " << index+1 << endl;
cin >> values[index];
if (values[index] >= iMax) {
iMax = values[index];
}
if (values[index] <= iMin) {
iMin = values[index];
}
}
// free up the allocated memory
delete values;
cout << "Minimum value was " << iMin << endl;
cout << "Maximum value was " << iMax << endl;
} else {
cout << "Error: Unable to allocate memory for " << iCount << " values." << endl;
}

} else {
cout << "Nothing to do (Zero integers to compare)" << endl;
}
return 0;
}``````
commented: Good job! Now he can cheat his way to an A -3

## WaltP 2,905

Consider:

Assume that the first integer read specifies the number of values remaining to be entered and that the first number is not one of the integers to compare.

What is the purpose of the first number to be read? How would you use it?
What is the purpose of the 6 in your `while` statement?

Write a program that finds both the largest and smallest of several integers.

How would you do this on paper?

To chief427:
What grade to you expect to get for your code? What grade should lou38 get using your code? Please do not give working programs to students. We help people solve their problems so they learn, not write the code for them so they can cheat.

commented: Daniweb described in simplest words :) +2

## chief427 -3

My apologies. I simply thought someone had a problem and needed help.
Is this (site) all about helping students or is it about programming problems generally ?
I don't care what grade I get for my code, only that it works. If I have learnt one thing in 20+ years of programming it is that there is a significant difference between what is expected by an academic in an assignment and what is expected by an employer in your job.

## WaltP 2,905

My apologies. I simply thought someone had a problem and needed help.

And you were correct. As the OP stated "I need help with this assignment,..."

Is this (site) all about helping students or is it about programming problems generally ?

Both. But it's not about writing code for someone. It's about helping them solve their own problems and thereby learn.