write a program to find the number of even integers and odd
integers in a given array in c language
Answer Posted / ankit kr. sharma
#include<stdio.h>
#include<conio.h>
void main()
{
int a[10],i,neg=0,even=0,odd=0;
printf("Enter the elements for the array:\n");
for(i=0;i<10;i++)
{
scanf("%d",&a[i]);
}
printf("The array is:");
for(i=0;i<10;i++)
{
printf("%d\t", a[i]);
}
for(i=0;i<10;i++)
{
if (a[i]<0)
neg++;
else if(a[i]%2==0)
even++;
else
odd++;
}
printf("\nthe odd no.s in the array are: %d\t",odd);
printf("\nthe negative no.s in the array are: %d\t",neg);
printf("\nthe even no.s in the array are: %d\t",even);
}
| Is This Answer Correct ? | 10 Yes | 11 No |
Post New Answer View All Answers
How can I manipulate strings of multibyte characters?
What is string concatenation in c?
Why do we need functions in c?
What is calloc in c?
Tell me the use of bit field in c language?
What is meant by realloc()?
Explain the properties of union.
What are the types of pointers in c?
What is openmp in c?
Are enumerations really portable?
What is the code for 3 questions and answer check in VisualBasic.Net?
Combinations of fibanocci prime series
Explain can you assign a different address to an array tag?
The difference between printf and fprintf is ?
What is advantage of pointer in c?