Google results only show how to display highest and lowest of numbers already assigned inside an array which i already know and not how to display highest and lowest of numbers i entered through the keyboard.
int largest = INT_MIN, lowest = INT_MAX, num;
/*INT_MAX and INT_MIN represent the largest and lowest possible integers(int)*/
while(cin >> num)//use CTRL + D (end-of-file) to exit loop
{
lowest = min(lowest, num);//returns the lesser value of the two
largest = max(largest, num);//returns the higher value
}
cout << "The largest is: " << largest
<< " and the lowest is: " << lowest << endl;
No, it's not. The >> function reads ints from the stream cin until the End-of-File character is read. That can be done by entering CTRL+Z or CTRL+D. Sorry I forgot to mention that. So after antering all numbers, enter the End-of-File to exit the loop.