Advertisement
Guest User

Untitled

a guest
Jul 26th, 2016
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. #include <iostream>
  2. #include <time.h>
  3. #include <stdlib.h>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9. int num1;
  10. srand(time(NULL));
  11. int even, odd;
  12.  
  13. even = 0;
  14. odd = 0;
  15. int array1[10] = {0};
  16.  
  17. for (int i=0; i<10; i++)
  18. {
  19. array1[i] = rand()%20+1;
  20. cout<<array1[i]<<" ";
  21. if (array1[i] %2 ==0)
  22. even++;
  23. else
  24. odd++;
  25. }
  26.  
  27. cout<<"there are "<<even<<" evens and "<<odd<<" odds!"<<endl;
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36. return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement