#include<stdio.h>
int* count(int a[],int n,int ele)
{
int i,c[3]={0,0,0};
for(i=0;i<n;i++)
{
if(a[i]==ele)
c[0]++;
else if(a[i]<ele)
c[1]++;
else
c[2]++;
}
return c;
}
main()
{
int a[100],n,i,*cnt,item;
printf("\nEnter number of terms=");
scanf("%d",&n);
printf("\nEnter the integers=");
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
printf("\nThe array elements are=");
for(i=0;i<n;i++)
{
printf("%d ",a[i]);
}
printf("\nEnter a number=");
scanf("%d",&item);
cnt=count(a,n,item);
printf("\nNumber of elements equale to %d=%d\nNumber of elements less than %d=%d\nNumber of elements greater than %d=%d\n",item,cnt[0],item,cnt[1],item,cnt[2]);
}
int* count(int a[],int n,int ele)
{
int i,c[3]={0,0,0};
for(i=0;i<n;i++)
{
if(a[i]==ele)
c[0]++;
else if(a[i]<ele)
c[1]++;
else
c[2]++;
}
return c;
}
main()
{
int a[100],n,i,*cnt,item;
printf("\nEnter number of terms=");
scanf("%d",&n);
printf("\nEnter the integers=");
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
printf("\nThe array elements are=");
for(i=0;i<n;i++)
{
printf("%d ",a[i]);
}
printf("\nEnter a number=");
scanf("%d",&item);
cnt=count(a,n,item);
printf("\nNumber of elements equale to %d=%d\nNumber of elements less than %d=%d\nNumber of elements greater than %d=%d\n",item,cnt[0],item,cnt[1],item,cnt[2]);
}
No comments:
Post a Comment