• Skip to main content
  • Skip to footer

CS50's Introduction to Computer Science on Edx: Supplementary resource

CS50 threads to aide as a supplementary resource

Unable to move to the next chunk of the problem

CS50 threads to aide as a supplementary resource › Forums › CS50’s Introduction to Computer Science by Harvard University on Edx › Week 1 › Unable to move to the next chunk of the problem

Tagged: credit card project, infinite loop, while loop

  • This topic is empty.
Log In Register Lost Password
Viewing 1 post (of 1 total)
  • Author
    Posts
  • September 28, 2021 at 8:49 am #104
    admin
    Keymaster


      Copy Code
      Copied
      Use a different Browser

      
      
      #include <cs50.h>
      #include <stdio.h>
      int main(void)
      {
      long creditcardno;
      do
      {
          creditcardno = get_long("enter");
      }
      while (creditcardno < 1000000000000 || creditcardno > 9999999999999999);
      int i = 0;
      long cc = creditcardno;
      while (cc > 0)
      {
          cc = creditcardno / 10;
          i++;
      }
      printf("%d", i);
      }

      After accepting the input of number between 1000000000000 and 9999999999999999, the program seems get into some kind of infinite loop.

      enter image description here

       


      Reply


      https://cs50.stackexchange.com/questions/41960/unable-to-move-to-the-next-chunk-of-the-problem[learn_press_profile]

    • Author
      Posts
    Log In Register Lost Password
    Viewing 1 post (of 1 total)
    • You must be logged in to reply to this topic.
    Log In

    Log in / Register

    Initiative by Digital Splendid OPC Pvt. Ltd.