Posted By:
23 Jun, 2013 1:18 pm PDT

Creating histogram in C

How to create histograms in C?
Attachment:None


To create histograms we use the following logic:

for(n=0;n<N;++n)

{

    printf("Enter employees in group - %d :",n+1);

    scanf("%d",&x);

    value[n]=x;

}

printf("\n");

for(n=0;n<N;++n)

{

    for(i=2;i<=3;i++)

    {

        if(i==2)

            printf("Group-%d|",n+1);

            if(i==3)

                printf("\n       |");

                for(j=1;j<=value[n];++j)

                    printf("*");

                   

                    if(i==2)

                        printf("(%d)",value[n]);

                        else

                            printf("\n");

                            }

    printf("\n");

}

 Please see the video for more details.

Was it useful?  




Please login to reply to this problem.