Thread: Question to a problem

  1. #1
    Registered User
    Join Date
    Oct 2017
    Posts
    1

    Question to a problem

    Hello guys! Just created an account solely for this question because I couldn't find a specific answer in Google. So I'm hoping this would be a better platform to be guided along with this problem I'm facing.

    Question to a problem-capture-png

    The 6 Digit OTP output should be in the order: (remainder 1)(remainder 2)(Last 2 digits) and as you can see, it seems to be in order however, whenever there's a "0" in either 1 of the value, the output doesn't seem to show it.

    I used printf("%d%d%d", remainder1,remainder2,last2digits) and all three variables are set to int so for the life of me I can't figure out why the output would not display the 0.

    Thus, I was hoping to learn what kind of problem this is so I can further research and hopefully solve my coding problem.

    Thanks so much guys!

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Try "%02d" as a format.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. question on k&r problem
    By ioil in forum C Programming
    Replies: 4
    Last Post: 08-03-2010, 07:58 PM
  2. Pointer problem/question...
    By tyskater in forum C Programming
    Replies: 2
    Last Post: 10-21-2003, 11:04 PM
  3. resource problem/question
    By stallion in forum Windows Programming
    Replies: 4
    Last Post: 01-29-2003, 02:08 PM
  4. problem with my array question
    By datainjector in forum C Programming
    Replies: 6
    Last Post: 08-01-2002, 02:39 PM
  5. STL Problem & Question
    By kuphryn in forum C++ Programming
    Replies: 0
    Last Post: 12-04-2001, 07:19 PM

Tags for this Thread