I need help creating a program which prints a line of n copies of the character c followed by a new line.and then use this code to print out a simple barchart illustrating the numbers read in from the command line.
I have created the code for the first part (shown below)
#include <iostream>
usingnamespace std;
void line (int n, char c)
{
// this is the loop for n
for (int i = 0; i < n; i++)
cout << c << endl;
}
int main(void)
{
int Number;
char Char;
cout << "Enter a number: " ;
cin >> Number ;
cout << "\nEnter a letter: " ;
cin >> Char ;
line (Number, Char) ;
}
But i need help so this code can be used to read in numbers from the command line to print a simple barchart in this format:
The thing is really i shouldnt be using the <iomanip> as I havn't learned it yet! And the user needs to be able to enter numbers from the command line so that the numbers can be transfered into the * characters in the graph.
But then how to i use this code to help me with my original question so that the user enters a certain number of numbers in the command line and these are output into a graph in this format:
The line function that you posted would work, if you remove "<< endl" from the line that prints the character(s) and add "cout << endl;" on a separate line. For each line, you only want one newline at the end, not a newline between each character.