write a program to find the frequency of a number

Answers were Sorted based on User's Feedback



write a program to find the frequency of a number..

Answer / md abdul khader

#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int n,a[100],b[100],i,test=0,j,count=0;
cout<<"The size of your digit : ";
cin>>n;
cout<<"Enter the digits of your number : "<<endl;
for(i=0;i<n;i++)
{
cin>>a[i];
}
for(j=0;j<=9;j++)
{
for(i=0;i<n;i++)
{
if(a[i]==j)
count++;
}
b[j]=count;
count=0;
}
cout<<"Your number is : ";
for(i=0;i<n;i++)
{
cout<<a[i];
}
cout<<"\nDesired Output is : "<<endl;
for(i=0;i<=9;i++)
{
cout<<i<<" : ";
while(test<b[i])
{
cout<<"* ";
test++;
}
test=0;
cout<<endl;
}
getch();
}

Is This Answer Correct ?    17 Yes 10 No

write a program to find the frequency of a number..

Answer / vikky_manit

#include<stdio.h>
void main()
{
int a[10],n,key,count=0;
printf("Enter the number of elements\n");
scanf("%d",&n);
printf("Enter %d elements\n",n);
for(i=0;i<n;i++)
scanf("%d",&a[i]);
printf("Enter the element whose frequency is to be
determined\n");
scanf("%d",key);
for(i=0;i<n;i++)
if(key==a[i])
count++;
printf("Frequency=%d",count);
}

Is This Answer Correct ?    39 Yes 36 No

write a program to find the frequency of a number..

Answer / veeraj.j

#include<stdio.h>
void main()
{
int a[10],n,key,count=0;
printf("Enter the number of elements\n");
scanf("%d",&n);
printf("Enter %d elements\n",n);
for(i=0;i<n;i++)
scanf("%d",&a[i]);
printf("Enter the element whose frequency is to be
determined\n");
scanf("%d",&key);
for(i=0;i<n;i++)
if(key==a[i])
count++;
printf("Frequency=%d",count);
}

Is This Answer Correct ?    11 Yes 16 No

write a program to find the frequency of a number..

Answer / pratik roy

#include<stdio.h>
#include<conio.h>

void freq(int ,int ,int );

int main()
{
int a,key,count,i;
printf("Enter the elements\n");
scanf("%d",&a);
printf("Enter the element whose frequency is to be determined\n");
scanf("%d",&key);
freq(a,key,0);
getch();
return 0;
}

void freq(int num,int key,int count)
{
int samkey,i;
i=num/10;
if(i!=0)
{
samkey = num%10;
if(samkey == key ) {count++; freq(num,key,count);}
else
{
num=num/10;
freq(num,key,count);
}
}
printf("%d",count);
}

Is This Answer Correct ?    4 Yes 10 No

Post New Answer

More C Interview Questions

Explain how can you determine the size of an allocated portion of memory?

0 Answers  


If one class contains another class as a member, in what order are the two class constructors called a) Constructor for the member class is called first b) Constructor for the member class is called second c) Only one of the constructors is called d) all of the above

0 Answers  


Difference between C and Embedded C?

1 Answers  


What is queue in c?

0 Answers  


What does the c in ctime mean?

0 Answers  


Write a program or provide a pseudo code to flip the 2nd bit of the 32 bit number ! (Phone Screen)

1 Answers   NetApp, PTU, Wipro,


Give the Output : * * * * * * * * * *

2 Answers  


What is the use of define in c?

0 Answers  


i want to know aptitude questions,technical questions

2 Answers  


whitch value return void main?

11 Answers  


how to sort two array of characters and make a new array of characters.

1 Answers   Accenture,


What is the difference between a string copy (strcpy) and a memory copy (memcpy)? When should each be used?

0 Answers   Aspire, Infogain,


Categories