12. 5.16 (Bar-Chart Printing Program) One interesting application of computers is to display graphs and bar charts. Write an application that reads five numbers between 1 and 30. For each number that’s read, your program should display the same number of adjacent asterisks. For example, if your program reads the number 7, it should display *******. Display the bars of asterisks after you read all five numbers
Code:
#include<iostream>
using namespace std;
int main()
{
int a, b, c, d, e;
cout << "Enter five integers (between 1 and 30) : ";
cin >> a >> b >> c >> d >> e;
for( int i = 1; i <= a; i++)
{
cout << "*";
}
cout << endl;
for( int i = 1; i <= b; i++)
{
cout << "*";
}
cout << endl;
for( int i = 1; i <= c; i++)
{
cout << "*";
}
cout << endl;
for( int i = 1; i <= d; i++)
{
cout << "*";
}
cout << endl;
for( int i = 1; i <= e; i++)
{
cout << "*";
}
cout << endl;
return 0;
}