write a program to find the number of even integers and odd
integers in a given array in c language
Answer Posted / ravestar
#include<stdio.h>
#include<iostream.h>
#include<conio.h>
main()
{clrscr();
int a[5],count_even=0,count_odd=0,i;
for(i=0;i<5;i++)
scanf("%d",&a[i]);
for(i=0;i<5;i++)
{
if((a[i]%2 ==0))
count_even++;
if((a[i]%2==1))
count_odd++;
}
cout<<"Even:"<<count_even<<"\n"<<"Odd:"<<count_odd;
getch();
}
| Is This Answer Correct ? | 8 Yes | 7 No |
Post New Answer View All Answers
What is a stream?
Explain logical errors? Compare with syntax errors.
What is the total generic pointer type?
What is the advantage of using #define to declare a constant?
the portion of a computer program within which the definition of the variable remains unchanged a) mode b) module c) scope d) none
Once I have used freopen, how can I get the original stdout (or stdin) back?
what will be maximum number of comparisons when number of elements are given?
How many main () function we can have in a project?
Do array subscripts always start with zero?
What is sizeof array?
How to set file pointer to beginning c?
Does sprintf put null character?
What is a structure and why it is used?
Can a variable be both static and volatile in c?
main() { printf("hello"); fork(); }