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
Write a C program in Fibonacci series.
What is a header file?
What is string constants?
the number of measuring units from a arbitrary starting point in a record area or control block to some other point a) branching b) recording pointer c) none d) offset
What is null pointer constant?
How can you read a directory in a C program?
Which is best linux os?
Explain how can you restore a redirected standard stream?
What are categories used for in c?
what are non standard function in c
How can I write data files which can be read on other machines with different word size, byte order, or floating point formats?
Write a code to remove duplicates in a string.
What functions are in conio h?
Is struct oop?
write a program that declares an array of 30 elements named "income" in the main functions. then cal and pass the array to a programmer-defined function named "getIncome" within the "getIncome" function, ask the user for annual income of 30 employees. then calculate and print total income on the screen using the following function: "void getIncome ( ai []);