Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <time.h>
- #include <stdlib.h>
- using namespace std;
- int main()
- {
- int num1;
- srand(time(NULL));
- int even, odd;
- even = 0;
- odd = 0;
- int array1[10] = {0};
- for (int i=0; i<10; i++)
- {
- array1[i] = rand()%20+1;
- cout<<array1[i]<<" ";
- if (array1[i] %2 ==0)
- even++;
- else
- odd++;
- }
- cout<<"there are "<<even<<" evens and "<<odd<<" odds!"<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement