Answer to Question #155860 in C++ for zain ul abdeen

Question #155860

Twenty-five numbers are entered from the keyboard into an array. Write a program to find out how many of them are positive, how many are negative, how many are even, and how many odd.


1
Expert's answer
2021-01-16T11:48:09-0500
#include<iostream>

using namespace std;

int main(){
    int numbers[25],even=0,odd=0,positive=0;
    for(int i=0;i<25;++i){
        cout<<"enter Number"<<i<<endl;
    cin>>numbers[i];

    if(numbers[i]>=0){ positive=positive+1;  }

    if(numbers[i]%2==0){ even=even+1;   }
    if(numbers[i]%2==1){ odd=odd+1; }

    }
    cout<<"odd numbers="<<odd<<"  even numbers="<<even<<"  positive numbers="<<positive<<endl;




return 0;


}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS