fork download
  1. //OrinTill Qimid CS1A Chapter 4, P. 294, 4
  2. //
  3. /**************************************************************
  4.  * Largest Number
  5.  *
  6.  * ____________________________________________________________
  7.  * This program will display the largest number out of the 10 number inputed.
  8.  * ____________________________________________________________
  9.  * INPUT
  10.  * Largest : the largest number
  11.  * smallest : the smallest number
  12.  *
  13.  * OUTPUT
  14.  * Num : The number input
  15.  **************************************************************/
  16. #include <iostream>
  17. #include <iomanip>
  18. #include <cmath>
  19. using namespace std;
  20.  
  21.  
  22.  
  23. int main()
  24. {
  25. int Num[10];
  26. int largest = Num[0];
  27. int smallest = Num[0];
  28. cout<<"Please enter 10 numbers"<<endl;
  29. for (int i = 0; i < 10; i++)
  30. {
  31. cout << "Enter value " << i + 1 << ": ";
  32. cin >> Num[i];
  33. if (Num[i] > largest) {
  34. largest = Num[i];
  35. }
  36. if (Num[i] < smallest) {
  37. smallest = Num[i];
  38. }
  39. }
  40. // Display the largest and smallest values
  41. cout << "The largest value is: " << largest << endl;
  42. cout << "The smallest value is: " << smallest << endl;
  43.  
  44. }
  45.  
  46.  
  47.  
Success #stdin #stdout 0.01s 5284KB
stdin
Standard input is empty
stdout
Standard output is empty