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 ;)

Friday, June 15, 2012

Finding Vertical Histogram of given set of data


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

int main()
  {
     clrscr();
     int i,j,k,c,num,mrk[10],max,tmp;
     do
     {
     printf("Enter the no. of cases (max. 10): ");
     scanf("%d",&num);
     }while(num<=0 || num>10);
     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]>32766 || mrk[i]<0 );
  if(max < mrk[i])
    max = mrk[i];
     }
     printf("\n\n All data has been collected !!");
     getch();
     clrscr();
     for(i=0;i<num;i++)
     {
      c = (mrk[i]*25)/max;
      //gotoxy(5+(5*i),0);
      for(k=0;k<c;k++)
      {
for(j=0;j<3;j++)
{
gotoxy(5+(5*i)+j,k);
printf("*");

}
      }
      gotoxy(5+(5*i),k);
      printf("%d",mrk[i]);

     }

     getch();
     return 0;
  }

No comments:

Post a Comment