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 insert or delete a line (or record) in the middle of a file?
What are the main characteristics of c language describe the structure of ac program?
What is the use of ?: Operator?
How can you be sure that a program follows the ANSI C standard?
What are the advantages and disadvantages of c language?
How can I read in an object file and jump to locations in it?
why we wont use '&' sing in aceesing the string using scanf
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
a single linked list consists of nodes a to z .print the nodes in reverse order from z to a using recursion
What the different types of arrays in c?
What are extern variables in c?
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.
What are the 4 types of unions?
How do you print only part of a string?
What is the use of getchar functions?