/* C Program to find th information Content OF the 5 message entered by the user */

#include< stdio.h>

#include< conio.h>

#include< math.h>

void main()

{

int c,i;

float p,sum=0,it;

clrscr();

printf("***** INFORMATION CONTENT OF FIVE MESSEGES *****\n\n");

printf("Enter No Of Messages : ");

scanf("%d",&c);

for(i=1;i< =c;i++)

{

printf("\tEnter The %d Probability\t: ",i);

scanf("%f",&p);

it=(log(1/p)) / log(2);

sum=sum+it;

}

printf("Information Content Of Given Message : %f",sum);

getch();

}

/********************* OUTPUT ***********************

***** INFORMATION CONTENT OF FIVE MESSEGES *****

Enter No Of Messages : 5

Enter The 1 Probability : 0.1

Enter The 2 Probability : 0.2

Enter The 3 Probability : 0.3

Enter The 4 Probability : 0.36

Enter The 5 Probability : 0.04

Information Content Of Given Message : 13.498609 */

## Tuesday, January 22, 2008

Subscribe to:
Post Comments (Atom)

## 4 comments:

Information Theory codes for RUn Length coding are nice..I am an Associate Professor..

gonna ask my students to do this assignment this week

keep up the good work..

will ask you few other codes as well

thanks again

nice work.I am an associate prof..gonna ask my students to write codes for rle coding

keep up the good work

thanks

#include

void main()

{

int a;

printf("Enter the number:");

scanf("%d",&a);

if (a%2!=0)

{

printf("\n the number %d is odd",a);

}

else if(a%2==0)

{

printf("\n the number %d is even",a);

}

}

#include

void main()

{

int a;

printf("Enter the number:");

scanf("%d",&a);

if (a%2!=0)

{

printf("\n the number %d is odd",a);

}

else if(a%2==0)

{

printf("\n the number %d is even",a);

}

}

Post a Comment