- This topic has 0 replies, 1 voice, and was last updated 4 years, 4 months ago by .
Viewing 1 post (of 1 total)
Viewing 1 post (of 1 total)
- You must be logged in to reply to this topic.
aiannum.com has rebranded as Progaiz.com
› Forums › CS50’s Introduction to Computer Science by Harvard University on Edx › Week 1: [C] – Data Types, Operators, Conditional Statements, Loops, and Command Line › Unable to move to the next chunk of the problem
Tagged: credit card project, infinite loop, while loop
[dm_code_snippet background=”yes” background-mobile=”no” slim=”yes” line-numbers=”yes” bg-color=”#abb8c3″ theme=”dark” language=”clike” wrapped=”yes” height=”” copy-text=”Copy Code” copy-confirmed=”Copied”]
#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);
}
[/dm_code_snippet]
After accepting the input of number between 1000000000000 and 9999999999999999, the program seems get into some kind of infinite loop.

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