Thread: Beginner's assignment: scan only 4 digit + number and separate its digit of ones.

  1. #1
    Registered User
    Join Date
    Apr 2020
    Posts
    6

    Beginner's assignment: scan only 4 digit + number and separate its digit of ones.

    Please help me it's duo today and I don't understand what I'm doing wrong, there's this weird 'bash: command not found' error.
    Beginner's assignment: scan only 4 digit + number and separate its digit of ones.-command-not-found-jpg

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    38,110
    Because your number is uninitialised, the while loop was initially false and the program just ends with no output.

    You typed 9999 at a new prompt, not in your program.
    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.

  3. #3
    Registered User
    Join Date
    Apr 2020
    Posts
    6
    Quote Originally Posted by Salem View Post
    Because your number is uninitialised, the while loop was initially false and the program just ends with no output.

    You typed 9999 at a new prompt, not in your program.
    Thanks for answering but I still can't make it work, could you please be more specific as for what should I do to fix it?
    Beginner's assignment: scan only 4 digit + number and separate its digit of ones.-desperation0-jpg

  4. #4
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    27,835
    Get rid of the spaces around the %i.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  5. #5
    Registered User
    Join Date
    Apr 2020
    Posts
    6
    Thanks it worked!! but now it keeps printing it endlessly, how do I restrict that to print the contents of the while loop only once? Edit: never mind I fixed it by switching the while loop to an if loop. Thank You all.
    Last edited by Null_Void; 04-07-2020 at 01:53 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Adding a number digit by digit.
    By sdfx in forum C Programming
    Replies: 4
    Last Post: 05-10-2011, 05:54 PM
  2. Replies: 2
    Last Post: 10-31-2009, 06:49 PM
  3. Adding a Large number digit by digit
    By mejv3 in forum C Programming
    Replies: 23
    Last Post: 09-21-2007, 03:00 PM
  4. Adding a Large number digit by digit
    By mejv3 in forum C Programming
    Replies: 1
    Last Post: 09-14-2007, 03:28 AM
  5. outputs number digit by digit
    By Unregistered in forum C++ Programming
    Replies: 14
    Last Post: 05-17-2002, 04:43 PM

Tags for this Thread