write a program to find the number of even integers and odd
integers in a given array in c language
Answer Posted / 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 View All Answers
When is a “switch” statement preferable over an “if” statement?
What is the purpose of & in scanf?
List the different types of c tokens?
Create a structure to specify data on students given below: Roll number, Name, Department, Course, Year of joining Assume that there are not more than 450 students in the college. 1.write a function to print names of all students who joined in a particular year 2.write a function to print the data of a student whose roll number is given
What is a rvalue?
What is the difference between malloc calloc and realloc in c?
How do you define structure?
Explain what is wrong with this statement? Myname = ?robin?;
The performance of an operation in several steps with each step using the output of the preceding step a) recursion b) search c) call by value d) call by reference
What are global variables?
What is a void pointer in c?
What is the use of typedef in structure in c?
What is the use of #define preprocessor in c?
What is the use of clrscr?
Why pointers are used?