1. ## max or min

say does anyone out there got a good algorithm for finding the max and min of two numbers here is the code that I have but I cant get the minimum to come out correct.
Code:
```#include <iostream>
#include <cstring>
using namespace std;

struct node
{
int info;
node *next;    //a pointer named node of size node(the structure in which it is contained)
};

int main()
{
int d=0, max=0, min=0, counter=0,a[5];
node *list;		   //a pointer called list of size node

node *p;		   //a pointer called p of size node

list = new(node);   //have list point to a new address

p=list;             //make both of those adresses the same

for(int i=0; i<5; ++i)
{
cout<<"Enter the value of this node: "<<endl;

cin>>p->info;//enter a value for the first

d=d+p->info;

a[i]=p->info;

counter++;

if(p->info> max)
{
max=p->info;

}
if(p->info<max)
min=p->info;

p->next=new(node);

p=p->next;
//this one works for sure
}
cout<<"THIS IS THE MAXIMUM NUMBER "<<max<<endl;
cout<<"THE AVERAGE IS: "<<d/counter<<endl;
cout<<"THE NUMBER OF VARIABLES IN THIS LINKED LIST IS "<<counter<<endl;
cout<<"THE MINIMUM IS "<<min<<endl;
cout<<list->info<<"  "<<list->next->info<<"  "<<list->next->next->info<<"  "<<list->next->next->next->info
<<"   "<<list->next->next->next->next->info<<"  "<<endl;
return 0;
}```

2. think your logic through one step at a time...

Code:
```if(p->info<max)
min=p->info;```
...so if a number is less than the max, that makes it the min? something is wrong here

also, your initializing the values to 0. this isnt a good idea.... ill let you think about why

3. the way i would do it is scan through the input numbers, find the largest. Than change the value your checking against to the found highest value, and work backwards through the input to find the lowest. Then you can find the average.

If you decide that the first number less than the largest is the minimum, your not being accurate in your data.

4. ## lost completely

Dude I'm not going to lie I'm completley lost I just need to see some basic code to get me on the right track

5. loop values and if greater than test value then process storage until you test it by the next value.

6. Originally Posted by drdodirty2002
Dude I'm not going to lie I'm completley lost I just need to see some basic code to get me on the right track
were only going to give you psudo code, we wont do the work for you. We've given you the advice, theres a board search, and theres a ton of webservers (google, eseek) for the same thing. Do some work, make an effort, then come back.

7. assign first value to both max and min. After all, since there are no other values it is both the max and the min. Then with each new value added compare it with max and min. If it is either greater than max or less than min then assign it to the appropriate variable.