Advertisement
Guest User

Untitled

a guest
Nov 12th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main() {
  6. int arraySize;
  7. cout<<"Input arraySize here";
  8. cin>>arraySize;
  9. int array[arraySize];
  10. cout<<"Print min value of array here";
  11. int min;
  12. cin>>min;
  13. cout<<"Print max value of array here";
  14. int max;
  15. cin>>max;
  16.  
  17. int pairNumSum = 0;
  18. int unpairedNumSum = 0;
  19.  
  20. for(int i=0; i<arraySize;i++){
  21. array[i] = rand()%(max-min+1) + max;
  22.  
  23. if (array[i]%2==0) {
  24. pairNumSum = pairNumSum + array[i];}
  25. else{
  26. unpairedNumSum=unpairedNumSum + array[i];}
  27. }
  28.  
  29. int result = pairNumSum - unpairedNumSum;
  30.  
  31. cout<<result;
  32.  
  33. return 0;}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement