I'm trying to write a program that asks the user for a number between 1 and 10, then prints a line of that many “X"s.
The program compiles, but I cannot figure out how to make the variable 'total' print X's instead of a the actual number, if that makes any sense. Thanks in advance.
#include <iostream>
#include <string>
using namespace std;
int main ()
{
int numExs;
string totalxs;
cout << "Please enter the number of Xs (1-10): ";
cin >> numExs;
if (numExs >= 1 && numExs <= 10)
{
int total = 0;
for (int x = 1; x <= numExs; x++)
{
total += x;
totalxs = total * 'X';
}
cout << totalxs;
}
else
{
cout << "Please follow the directions! " << endl;
}
}