Welcome

Hi! This blog is for beginners of c++ and java .You can check and pick codes for your programming assignments. This will also help you to understand the concepts of these programming languages. Its all about programming.

Bar Chart printing program By Students Numbers(By Arrays)

Tuesday, June 7, 2011

#include <iostream.h>
int main()
{
    const int arraysize=10;
    int a[arraysize];
    for (int b=0;b<arraysize;b++)
    {
        cout<<"Enter the number of students " << b <<": " ;
        cin>>a[b];
        cout<<endl;
    }
    for (int i=0;i<arraysize;i++)
    {
        if (i==0)
            cout <<" 0 - 9 : ";
        else if (i==100)
            cout <<"  100 : ";
        else
            cout <<i*10<<" - "<<(i*10)+9<<" : ";
        for (int stars=0;stars<a[i];stars++)
        cout <<"*";
        cout <<endl;
    }
    return 0;
}