Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>>
- using namespace std;
- int main()
- {
- double avg;
- bool is_prime=true;
- int a[100],n,sum=0,odd=0,even=0,min,max,product=1,moreavg,count=0,prnumb=0,qdrnumb=0,num_cpy;
- cout << "Enter number count: ";
- cin >> n;
- moreavg = 0;
- for (int i=0; i < n; i++){
- cout << "Enter a number: ";
- cin >> a[i];
- }
- for (int i=0; i < n; i++){
- if (a[i]%2==0){even++;}
- }
- for (int i=0; i < n; i++){
- if (a[i]%2==1){odd++;}
- }
- min = max = a[0];
- for (int i=0; i < n; i++){
- if (a[i]<min) {min=a[i];}
- }
- for (int i=0; i < n; i++){
- if (a[i]>max) {max=a[i];}
- }
- for (int i=0; i < n; i++){
- sum += a[i];
- }
- for (int i=0; i < n; i++){
- product *= a[i];
- }
- avg =(double) sum/n;
- for(int i=0; i<n; i++){
- if (a[i]>avg) {moreavg++;}
- }
- for(int i = 0; i < n; i++) {
- is_prime=true;
- for(int j = 2; j < a[i]; j++) {
- if(a[i]%j==0) {
- is_prime = false;
- }
- }
- if(is_prime==true) { prnumb++; }
- }
- for(int i = 0; i < n; i++) {
- num_cpy = a[i];
- count = 0;
- while(num_cpy!=0) {
- count += (num_cpy%2);
- num_cpy/=2;
- }
- if(count==1) { qdrnumb++; }
- }
- cout << endl;
- cout << "The sum of the numbers is: " << sum << endl;
- cout << "The product of the numbers is: " << product << endl;
- cout << "Min number: " << min << endl;
- cout << "Max number: " << max << endl;
- cout << "Even numbers: " << even << endl;
- cout << "Odd numbers: " << odd << endl;
- cout << "Average of the numbers: " << avg << endl;
- cout << "Numbers bigger than the Average: " << moreavg << endl;
- cout << "Prime numbers: " << prnumb << endl;
- cout << "Quadratic numbers: " << qdrnumb << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement