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

main() { enum _tag{ left=10, right, front=100, back}; printf("%d, %d, %d, %d", left, right, front, back); }

1 Answers   Accenture, Vector,


regarding the scope of the varibles;identify the incorrect statement: a.automatic variables are automatically initialised to 0 b.static variables are are automatically initialised to 0 c.the address of a register variable is not accessiable d.static variables cannot be initialised with any expression

1 Answers   TCS,


Write a program in "C" to calculate the root of a quadratic equation ax^2+bx+c=0, where the value of a,b & c are known.

0 Answers  


How can you invoke another program from within a C program?

0 Answers  


Explain enumerated types.

0 Answers  






where do we use volatile keyword?

1 Answers  


When should you not use a type cast?

0 Answers  


Can you write the algorithm for Queue?

0 Answers   College School Exams Tests, TCS,


int i=10; printf("%d %d %d", i, i=20, i);

0 Answers  


main() { printf("\n %d %d %d",sizeof('3'),sizeof("3"),sizeof(3)); } wat is the o/p and how?

12 Answers   Tech Mahindra,


What is the hardest programming language?

0 Answers  


How many types of errors are there in c language? Explain

0 Answers  


Categories