Write a C program to count and display positive, negative, odd and even numbers in an array.

Program Code:
#include<stdio.h>
void main()
{

int a[10],i,o=0,p=0,e=0,n=0;
printf(" enter 10 nos\n");
for(i=0;i<10;i++)
{
scanf("%d",&a[i]);
}
for(i=0;i<10;i++)
{
if(a[i]%2==0)
{
e++;
}
else
{
o++;
}
if(a[i]>=0)
{
p++;
}
else
{
n++;
}
}

printf("\n even nos.=%d",e);
printf("\n odd nos.=%d",o);
printf("\n +ve nos.=%d",p);
printf("\n -ve nos.=%d",n);
}
}
Mukesh Rajput

Mukesh Rajput

I am a Computer Engineer, a small amount of the programming tips as it’s my hobby, I love to travel and meet people so little about travel, a fashion lover and love to eat food, I am investing a good time to keep the body fit so little about fitness also..

Post A Comment:

0 comments: