Recent

Comments

Follow us on Facebook

Monday 27 November 2017

4. Five different numbers are input in an array. Write a program to determine how many of them are positive, negative, even and odd


Five different numbers are input in an array. Write a program to determine how many of them are positive, negative, even and odd

#include <iostream>
using namespace std;
main ()
{
int a[10],pos=0,neg=0,even=0,odd=0;
for(int i=0;i<10;i++)
{
cout<<"enter the number"<<i+1<<"   =  ";
cin>>a[i];
}
for (int i=0;i<10;i++)
{
if(a[i]>=0)
                  pos++;
            else
                  neg++;
            if(a[i]%2==0)
                  even++;
            else
                  odd++;
}
cout<<"positive number is = "<<pos<<endl;
cout<<"negative number is = "<<neg<<endl;
cout<<"even number is     = "<<even<<endl;
cout<<"odd number is      = "<<odd<<endl;
}

0 on: "4. Five different numbers are input in an array. Write a program to determine how many of them are positive, negative, even and odd"

Write a program, that takes 16-Elements in Two-Dimensional-Array that has 4 rows & 4 columns, then display the diagonal of Matrix.

Write a program, that takes 16-Elements in Two-Dimensional-Array that has 4 rows & 4 columns, then display the diagonal of Matrix. ...

propeller ads

PropellerAds