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


Please Help Members By Posting Answers For Below Questions

How can I insert or delete a line (or record) in the middle of a file?

579


What are the main characteristics of c language describe the structure of ac program?

616


What is the use of ?: Operator?

671


How can you be sure that a program follows the ANSI C standard?

1135


What are the advantages and disadvantages of c language?

569






How can I read in an object file and jump to locations in it?

583


why we wont use '&' sing in aceesing the string using scanf

1787


A variable that is defined in a specified portion of a program but can be used throughout the program a) global variable b) local variable c) character d) none

739


a single linked list consists of nodes a to z .print the nodes in reverse order from z to a using recursion

2338


What the different types of arrays in c?

618


What are extern variables in c?

553


write a program to reverse a every alternetive words in a string in a place. EX: Input is "this is the line of text" Output should be "shit is eht line fo text" Please any one tell me code for that.

1580


What are the 4 types of unions?

617


How do you print only part of a string?

620


What is the use of getchar functions?

683