Advertisement
Rehan_Rahman26

//array problem 1

Sep 29th, 2021
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.40 KB | None | 0 0
  1. //array problem 1
  2. #include <bits/stdc++.h>
  3. using namespace std;
  4. int main()
  5. {
  6.     int n,mx=0,mn=100000000;
  7.     cin >> n;
  8.     int ar[n];
  9.     for(int i=0; i<n; i++)
  10.     {
  11.         cin >> ar[i];
  12.         if(ar[i] > mx)
  13.             mx = ar[i];
  14.         if(ar[i]<mn)
  15.             mn = ar[i];
  16.     }
  17.     cout << "leargest value is: " << mx << endl << "smallest value is: " << mn << endl;
  18.     return 0;
  19. }
  20.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement