How JustAnswer Works:

  • Ask an Expert
    Experts are full of valuable knowledge and are ready to help with any question. Credentials confirmed by a Fortune 500 verification firm.
  • Get a Professional Answer
    Via email, text message, or notification as you wait on our site.
    Ask follow up questions if you need to.
  • 100% Satisfaction Guarantee
    Rate the answer you receive.

Ask Ansh P. Your Own Question

Ansh P.
Ansh P., Computer Software Specialist
Category: Programming
Satisfied Customers: 8148
Experience:  Professional software developer working as a systems engineer in top multi-national company.
14055801
Type Your Programming Question Here...
Ansh P. is online now
A new question is answered every 9 seconds

Write a procedure named Get_frequencies that constructs a

Customer Question

Write a procedure named Get_frequencies that constructs
a character frequency table. Input to the procedure should be a
pointer to a string, and a pointer to an array of 256 doublewords.
Each array position is indexed by its corresponding ASCII code. When
the procedure returns, each entry in the array contains a count of how
many times that character occurred in the string. Include the source code only.
Submitted: 7 years ago.
Category: Programming
Expert:  Ansh P. replied 7 years ago.

This is the program mentioned:

 

#include "stdio.h"
#include "conio.h"
#include "string.h"
void Get_frequencies(char *,double *);
void main(){
char *c;
double freq_table[256];
int i;
clrscr();
for(i=0;i<256;i++)
freq_table=0;
printf("\nEnter a string : ");
gets(c);
Get_frequencies(c,freq_table);
printf("\nThe Frequency Table\n");
for(i=0;i<256;i++){
printf("\n %c\t%d",(char)i,(int)freq_table);
if(i%10==0)//this is used only for the display purpose.
getch();
}
}
void Get_frequencies(char *s,double *count){
int i,j;
for(i=0;i<strlen(s);i++){
for(j=0;j<256;j++){
if(s==(char)j)
count[j]+=1;
}
}
}

Related Programming Questions