why cant we use directly an integer array instead of char array ?
Integer array instead of char array
@himanshuep32
Integer inputs are seperated by a space. You would have no way of stopping the entire 18 digit number from being taken input into the first cell of the array and the remaining blocks would remain empty. Character inputs can only take atmost a single character , whether or not they are seperated by space so character array or a string would work.
Alternatively if you still wish to work with numbers only and do not like the string method , take input into a long long int variable . It can store numbers as large as 18 digits.
long long int n;
cin >> n;
Now break this number down digit by digit and work on it. This is a bit tedious method and honestly , the character array method is better but this is if you wish to try.
Ohh!! Thanks for the instant and crisp clarification
@himanshuep32
You’re welcome.
Kindly mark your doubt as resolved as Resolved in your Doubts Section if your issue is solved. Or let me know if you any further queries regarding your doubt so I can help you out.