First of all, what you are doing is essentially printing chars with values from 0 to x. If you look up the ascii table here: http://www.asciitable.com/ you can look at the numeric value of the character and see what it represents as a char.
If it can not be represented, then console prints it out as squares you are seeing.
Now you are saying you want your code to be short and precise. Let me rework that a bit.
#include <iostream>
#include <string>
using namespace std;
string m(int x) {
string returnVal;
for (int i = 0; i < x; i++)
returnVal += (char)i;
return returnVal;
}
int main() {
int input;
cin >> input;
cout << m(input) << endl;
return 0;
}
Using letters as variable names is a terrible practice. Avoid that at all costs. Name your variables intuitively, so they are self describing. That is more important than having a "Short" and "precise" code.
Concerning that, you do not need the additional variable you named Q. You can directly typecast it into a char.
Also avoid using {} if you can. It decreases code complexity and increases readability