The BOTTOM LINE Quote Of The Day

The BOTTOM LINE Quote Of The Day

Don't Ever Tell GOD How BIG Your Problems are.
Just Tell Your Problems How BIG your GOD is ;)
Showing posts with label Statistics. Show all posts
Showing posts with label Statistics. Show all posts

Wednesday, June 13, 2012

Finding Horizontal Histogram of given set of data


#include<conio.h>
#include<stdio.h>

int main()
  {
     int i,j,k,c,num,mrk[100],max;
     printf("Enter the no. of cases : ");
     scanf("%d",&num);
     printf("\n\n");
   
     max = 0;
     for(i=0;i<num;i++)
     {
 do
      {
        printf("\nEnter frequency for Case #%d : ",i+1);
   scanf("%d",&mrk[i]);
 }while( mrk[i]>32767 || mrk[i]<0 );
  if(max < mrk[i])
    max = mrk[i];
     }
     printf("\n\n All data has been collected !!");
     getch();
   
     printf("\n\n\t\t\t\t HISTOGRAM \n");
     for(i=0;i<num;i++)
     {
      c = (mrk[i]*50)/max;
   
      for(k=0;k<3;k++)
      {
  if(k==1)
  { printf("\n Case #%d      ||  ",i+1); }
  else
  { printf("\n              ||  "); }

  for(j=0;j<c;j++)
    printf("*");

  if(k==1)
   printf("  %d",mrk[i]);
      }
      printf("\n");
      getch();            
     }  
     getch();
     return 0;
  }