write a program to find the number of even integers and odd
integers in a given array in c language

Answer Posted / anup majhi

#include<stdio.h>
#include<conio.h>
#define size 100
void check(int[],int);
int i;
main(){
int a[size],m
printf("Enter the array length ");
scanf("%d",&m);
printf("Supply elements to the array ");
for(i=0;i<m;i++)
scanf("%d",&a[i]);
check(a,m);
}
void check(int a[],int b){
int even=0,odd=0;
for(i=0;i<b;i++){
if(a[i]%2==0)
even++;
else
odd++;
}
printf("Number of even no. in the array =%d ",even);
printf("\nNumber of odd no. in the array =%d ",odd);
}


out put:
Enter the array length 5
Supply array elements 1 2 3 4 5
Number of even no. in the array =2
Number of odd no. in the array =3

Is This Answer Correct ?    11 Yes 4 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is a pointer and how it is initialized?

609


I need a sort of an approximate strcmp routine?

661


What is declaration and definition in c?

525


Why is c faster?

593


Draw a flowchart to produce a printed list of all the students over the age of 20 in a class .The input records contains the name and age of students. Assume a sentinel value of 99 for the age field of the trailer record

4742






Explain how can I write functions that take a variable number of arguments?

616


What does void main return?

606


Who developed c language and when?

586


What is cohesion and coupling in c?

591


What does c in a circle mean?

583


What is graph in c?

584


What are pragmas and what are they good for?

577


How do we open a binary file in Read/Write mode in C?

680


What is the most efficient way to count the number of bits which are set in an integer?

593


What do you mean by invalid pointer arithmetic?

637