Veson Nautical

  www.veson.com
  www.veson.com

Interview Question

Software Development Intern Interview(Student Candidate) Boston, MA

Write an integer-to-string function in C++.

Answer

Interview Answer

1 Answer

0

The answer involved dividing the integer by successively smaller amounts, relying on the fact that integer division floors the quotient, to "grab" characters corresponding to the numbers starting from the left and going to the right. There had to be three cases, one in which the number was negative, one in which it was zero, and one in which it was positive. Leading zeros should not be added to string.

Interview Candidate on May 1, 2012

Add Answers or Comments

To comment on this Question, Sign In with Facebook or Sign Up