write a program to find the number of even integers and odd
integers in a given array in c language
Answer Posted / ankit kumar sharma
#include<stdio.h>
#include<conio.h>
void main()
{
int a[5],count_even=0,count_odd=0,i;
printf("Enter the value in Array\n");
for(i=0;i<5;i++)
scanf("%d",&a[i]);
/* Calculating number of odd and even intergers */
for(i=0;i<5;i++)
{
if((a[i]%2 ==0))
count_even++;
if((a[i]%2==1))
count_odd++;
}
/* display the number of odd and even intergers */
printf(" Total number of even integer are %d\n ",count_even);
printf("Total number of odd integer are %d", count_odd);
getch();
}
| Is This Answer Correct ? | 13 Yes | 16 No |
Post New Answer View All Answers
Explain what’s a signal? Explain what do I use signals for?
Can the size of an array be declared at runtime?
Explain what is the difference between far and near ?
#include main() { int *p, *c, i; i = 5; p = (int*) (malloc(sizeof(i))); printf(" %d",*p); *p = 10; printf(" %d %d",i,*p); c = (int*) calloc(2); printf(" %d ",*c); }
How can I remove the leading spaces from a string?
Explain union. What are its advantages?
What is a #include preprocessor?
What is string function c?
What kind of structure is a house?
How do you print only part of a string?
WHAT IS THE DEFINATION OF IN TECHNOLOGY AND OFF TECHNOLOGY ?
A global variable when referred to in another file is declared as this a) local variable b) external variable c) constant d) pointers
What are the storage classes in C?
how to find anagram without using string functions using only loops in c programming
If a five digit number is input through the keyboard, write a program to print a new number by adding one to each of its digits.For example if the number that is input is 12391 then the output should be displayed as 23402