# include <iostream.h>
// Construct a user defined array of 10 integers.
// Count the even and odd integers in the array and display the counts.
void main()
{
int a[10], i;
int even = 0;
int odd = 0;
for(i = 0; i<10 ;i++)
{
cout<<"enter an integer for location a["<<i<<"]: ";
cin>>a[i];
if(a[i]%2 == 0)
{
even++;
}
else
{
odd++;
}
}
cout<<"the array has "<<even<<" even numbers"<<endl;
cout<<"the array has "<<odd<<" odd numbers"<<endl;
}
// Construct a user defined array of 10 integers.
// Count the even and odd integers in the array and display the counts.
void main()
{
int a[10], i;
int even = 0;
int odd = 0;
for(i = 0; i<10 ;i++)
{
cout<<"enter an integer for location a["<<i<<"]: ";
cin>>a[i];
if(a[i]%2 == 0)
{
even++;
}
else
{
odd++;
}
}
cout<<"the array has "<<even<<" even numbers"<<endl;
cout<<"the array has "<<odd<<" odd numbers"<<endl;
}
0 comments:
Post a Comment