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

Answers were Sorted based on User's Feedback



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

Answer / nikhil patil

#include<stdio.h>
#include<conio.h>main()
{
int a[5],even=0,odd=1,i;

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

scanf("%d",&a[i]);
/* display the number of odd and even intergers */
for(i=0;i<5;i++)
{
if((a[i]%2 ==0))
even++;
if((a[i]%2==1))
odd++;
}
printf("%d",even,);
printf ("%d",odd,);
getch();

Is This Answer Correct ?    32 Yes 44 No

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

Answer / april

#include<stdio.h>
#include<conio.h>

using namespace std;
int main();
{
int i,j;
int num[20],i,odd=0,even=0,n;
cout<<("enter the size of the array",n);
cin>>("%d",&n);

cout<<("Enter the %d array elements",n);
for(i=20;i<n;i++);
{
cout<<("%d",&num[i]);
}
for(i=0;i<n;i++);
{
if(num[i]%2==0);
{
even++;
}
else
{
odd++;
}
}
cout<<("\n The number of even numbers in the array :%
d ",even);
cout<<("\n The number of odd numbers in the array : %
d",odd);
getch();
system("pause");
}

Is This Answer Correct ?    25 Yes 37 No

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

Answer / jasna.c

#include<stdio.h>
#include<conio.h>
void main()
{
int arr[100],i,odd=0,even=0,n;
printf("enter the size of the array");
scanf("%d",&n);
printf("Enter the %d array elements",n);
for(i=0;i<n;i++)
{
scanf("%d",&arr[i]);
}
for(i=0;i<n;i++)
{
if(arr[i]%2==0)
{
even++;
}
else
{
odd++;
}
}
printf("\n The number of even numbers in the array :%d ",even);
printf("\n The number of odd numbers in the array : %d",odd);
getch();
}

Is This Answer Correct ?    26 Yes 41 No

Post New Answer

More C Interview Questions

Given a single Linked list with lakhs of nodes and length unknown how do you optimally delete the nth element from the list?

1 Answers   Oracle,


Array is an lvalue or not?

0 Answers  


fn f(x) { if(x<=0) return; else f(x-1)+x; }

5 Answers   HCL,


What is a substring in c?

0 Answers  


Why does the call char scanf work?

0 Answers  






Is this program statement valid? INT = 10.50;

0 Answers  


Write a c pgm for leap year

11 Answers   College School Exams Tests, IBM, TCS,


what is d pitfalls of registers variables

3 Answers   TCS,


hi , please send me NIC written test papers to sbabavalli@gmail.com

0 Answers   NIC,


Can main () be called recursively?

0 Answers  


write a program that types this pattern: 12345678987654321 12345678 87654321 1234567 7654321 123456 654321 12345 54321 1234 4321 123 321 12 21 1 1

0 Answers  


HOW CAN ADD OUR FUNCTION IN LIBRARY.

5 Answers  


Categories