/*Serial No.82 [swami56.cpp]*/
#include<stdio.h>
#include<conio.h>
void main()
{
int num,i,arr[5],count1=0,count2=0,flag=0;
printf("Enter 5 numbers for array:=");
for(i=0;i<5;i++)
{
scanf("%d",&arr[i]);
}
printf("Enter number to find the frequency:=");
scanf("%d",&num);
for(i=0;i<5;i++)
{
if(arr[i]==num)
{
count1++;
flag=1;
}
}
if(flag==1)
{
printf("frequency of %d := %d\n",num,count1);
}
for(i=0;i<5;i++)
{
if(arr[i]!=num)
{
count2++;
}
}
if(count2==5)
{
printf("Number %d does not exist in present array",num);
}
getch();
}
#include<stdio.h>
#include<conio.h>
void main()
{
int num,i,arr[5],count1=0,count2=0,flag=0;
printf("Enter 5 numbers for array:=");
for(i=0;i<5;i++)
{
scanf("%d",&arr[i]);
}
printf("Enter number to find the frequency:=");
scanf("%d",&num);
for(i=0;i<5;i++)
{
if(arr[i]==num)
{
count1++;
flag=1;
}
}
if(flag==1)
{
printf("frequency of %d := %d\n",num,count1);
}
for(i=0;i<5;i++)
{
if(arr[i]!=num)
{
count2++;
}
}
if(count2==5)
{
printf("Number %d does not exist in present array",num);
}
getch();
}
No comments:
Post a Comment
If you have any doubt, feel free to ask...