finding greatest and largest number of random set of integers

i am writing a program for class that prompts the user for a positive integer, then will end when the user enters 0. you cant use negative integers. it then asks you to find the largest and smallest value of those values you just entered (only positive ones).
I need help finding the largest and smallest value.


#include <iostream>
using namespace std;
int main()
{
int num, largest, smallest;

cout << "Please enter positive integer values.\n";
cout << "I Will read these values until you enter zero. \n";
cin >> num;

while (num != 0)
{

if (num < 0)
cout << num << " is negative!!!! I told you to enter POSITIVE integers only.\n" << "Why didn't you listen?\n" << "Enter another positive integer.\n";
else (num > 0);
cin >> num;
}
cout << "Your greatest positive integer entered is " << largest << endl;
cout << "Your smallest positive integer entered is " << smallest << endl;

system ("pause");
return 0;
}

1.-If num is not 0 and is not less than 0,
Then, its greater than 0 -positive,
you don't have to check if (num >0)

by the way you have
1
2
3
else (num>0)
instead of
else if(num>0)

Topic archived. No new replies allowed.