AshfaqFardin

Find the maximum value (using array)

Jul 30th, 2021
720
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     int findMax[3];
  8.    
  9.     cout << "Enter three inputs: \n";
  10.     for(int i = 0; i < 3; i++){
  11.         cin >> findMax[i];
  12.     }
  13.    
  14.     //find the max
  15.     int max = findMax[0];
  16.     for(int i = 0; i < 3; i++){
  17.         if(max < findMax[i]){
  18.             max = findMax[i];
  19.         }
  20.     }
  21.    
  22.     cout << "The max value is: " << max;
  23.    
  24.     return 0;
  25. }
  26.  
RAW Paste Data