write a program to find the frequency of a number
Answers were Sorted based on User's Feedback
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 |
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 |
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 |
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 |
main() { enum _tag{ left=10, right, front=100, back}; printf("%d, %d, %d, %d", left, right, front, back); }
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
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.
How can you invoke another program from within a C program?
Explain enumerated types.
where do we use volatile keyword?
When should you not use a type cast?
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);
main() { printf("\n %d %d %d",sizeof('3'),sizeof("3"),sizeof(3)); } wat is the o/p and how?
What is the hardest programming language?
How many types of errors are there in c language? Explain