Im working through accelerated c++ book and in chapter 4 ex 2 i had to build a program that displayed the square of ints (i) 1->100 inclusive using setw() to align the results.
this i did ok and it works fine like 3 lines of code.
However in ex4.3 it says
"rewrite the program to be more robust in the faces of changes that allow i to grow without adjusting the setw arguments"
To do this i have an idea but i dont know if its what the autor means or something else.
Idea: get the largest size of i permissable calculate the width it would require to be displayed for the number itself and the square and store this in a var. then loop through 1->i and print results.
Why i think thats wrong is: does that really meet what the question asks for as i can grow but we have to know the maximum value as before. is simply asjusting the argument to setw based on an initial calculation like this really all the solution would need to solve the question correctly?
I hope this does not seem like too daft a question and its just me overthinksing things