Author Topic: do-while loop  (Read 10579 times)


  • Guest
do-while loop
« on: October 15, 2012, 08:38:04 pm »
Hello everybody!

I have a problem with the usage of do-while loop in code blocks.

The problem is that it somehow HAS to run at least once. The part of my program is:

printf("Enter number e: \n");
scanf("%f", &e);

        printf("Enter number e: \n");
        scanf("%f", &e);
    while(e<0.0001 || e>0.1);

If I enter 0.01 for example, I get the message again and when I enter 0.01 again, the program goes out of the loop. Shouldn't it skip the do part and continue without the loop after the first input?

Offline Martin K.

  • Multiple posting newcomer
  • *
  • Posts: 86
Re: do-while loop
« Reply #1 on: October 15, 2012, 09:21:17 pm »
It does exactly what you have coded and this is not a Code::Blocks thing.
Search for a c/c++ Forum.