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;