Average number of bits per codeword in C++

#include<iostream.h>
#include<conio.h>
#include<math.h>
#include<string.h>
void main()
{
  clrscr();
  char str[5];
  float freq[5];
  float code[5];
  float avg[5];
  cout<<"\n Enter the text: ";
  cin>>str;
  for(int i=0;i<strlen(str);i++)
  {
    cout<<"\n Enter frequency of  "<<str[i]<<" ";
    cin>>freq[i];
    cout<<"\n Enter length  of codeword  "<<str[i]<<" ";
    cin>>code[i];
    avg[i]=freq[i]*code[i];
  }
  for(i=0;i<strlen(str);i++)
  {
      cout<<"\n Average number of bits for "<<str[i]<<" : "<<avg[i];
  }
  getch();
}

Comments

Popular posts from this blog

Silde show of images In JSP

Compression ratio, Compression factor, saving percentage in C++

Working with database in Vb.net