Question icon
Grade 12Discuss with colleagues and IITians

Write a program in C++ to input 10 numbers in array and show how many are even and how many are odd?

plz reply ..i'll surely approve that...

Profile image of Gurwinder Kaur
14 Years agoGrade 12
Answers icon

2 Answers

Profile image of Vinayak Gupta
ApprovedApproved Tutor Answer14 Years ago

The required program is :

========================================================

#include<iostream.h>

#include<conio.h>

void main()

{ clrscr(); 

  int a[10],i,j;

    int even=0,odd=0;

cout<<"enter the elements of the array"<<endl;

 for(i=0;i<10;++i)

{

cin>>a[i];

}

for(j=0;j<10;++j)

{  

   if (a[i]%2==0)

   even=even+1;

 

   else

   odd=odd+1;

}

cout<<"the number of even numbers are"<<even<<endl;

cout<<"the number of odd numbers are"<<odd<<endl;

getch();

}

=========================================================

approve the answer if helpful

Profile image of MALEPATI BALA SIVA SAI AKHIL
ApprovedApproved Tutor Answer14 Years ago

#include<iostream.h>

#include<conio.h>

void main()

{

 int ar[15];

 cout<<"PLEASE INPUT THE NUMBERS:";

 for(int i=0;i<10;i++)

 {

  cin>>ar[i];

 }

int even,odd;

for(i=0;i<10;i++)

 {

  if(ar[i]%2==0)

  ++even;

  else

  ++odd;

 }

 cout<<"THE NUMBER OF EVEN NUMBERS ARE:"<<even;

 cout<<"THE NUMBER OF ODD NUMBERS ARE:"<<odd;

}

PLEASE DONT FORGET TO APPROVE THE ANSWER IF IT IS HELPFUL TO YOU.