Why the output is coming 8 for every input?

please see my code on https://ide.codingblocks.com/s/147906

@Ignitor i think your logic is wrong as I can see that you have not taken any n as input in your program you can use stl function of to_string functin of string class to convert it directly

can you explain somehing about that to string function with example

@Ignitor hey kartik this is stl function of string class for better exploration see this
http://www.cplusplus.com/reference/string/to_string/