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.
#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;
}
Comments
Leave a comment