#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;
}
No comments:
Post a Comment