Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

write a program to display the frequency of each element in
a given array in c language

Answer Posted / gaurav gangopadhyay

#include<stdio.h>
#include<conio.h>
void main()
{
char ch[10],stk[10];
int i=0;frq[10],b=-1,k,j;
printf("Enter string:");
gets(ch);
while(ch[i]!='\0')
{
if(b==-1)
{
b++;
stk[b]=ch[i];
frq[b]=frq[b]+1;
}
else
{
k=0;
for(j=0;j<=b;j++)
{
if(stk[j]==ch[i])
{
frq[j]=frq[j]+1;
k=1;
break;
}
}
if(k==0)
{
b++;
stk[b]=ch[i];
frq[b]=frq[b]+1;
}
}
i++;
}
for(i=0;i<=b;i++)
printf("\nNo of %c=%d",stk[i],frq[i]);
getch();
}

Is This Answer Correct ?    4 Yes 12 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Declare the structure which contains the following members and write in C list of all students who score more than 75 marks. Roll No, Name, Father Name, Age, City, Marks.

1339


What are the advantages and disadvantages of a heap?

1218


What is openmp in c?

1028


Why void main is used in c?

1062


How can I get back to the interactive keyboard if stdin is redirected?

1196


What is #line?

1067


In which layer of the network datastructure format change is done

1894


Differentiate Source Codes from Object Codes

1594


void main(){ int a; a=1; while(a-->=1) while(a-->=0); printf("%d",a); }

1731


write a c program for swapping two strings using pointer

2641


Can you tell me how to check whether a linked list is circular?

1434


Can a function be forced to be inline? Also, give a comparison between inline function and the C macro?

1113


A c program to display count values from 0 to 100 and flash each digit for a secong.reset the counter after it reaches 100.use for loop,. pls guys hepl me.. :(

2258


Which driver is a pure java driver

1632


What is the difference between int main and void main in c?

1188