473,327 Members | 1,979 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

why while(10) excuate body infinity times ???

what does 10 means in while(10) and why it excuate infinity times like while (1) iz 10 also means true same like 1 ?????
Apr 12 '14 #1
8 1534
weaknessforcats
9,208 Expert Mod 8TB
while(10) is the same as while(1) or any other symbolic constant.

It means that the loop runs forever.

You usually see this in a menu driver:

Expand|Select|Wrap|Line Numbers
  1. int choice;
  2. while(1)
  3. {
  4.  
  5.   choice = getChoice();
  6.   switch (choice)
  7.   {
  8.      case 1:
  9.        ..this is menu choice 1...
  10.        break;
  11.      case 2: 
  12.        .. this is menu choice 2..
  13.        break;
  14.      default:
  15.         ...this is a bad choice..
  16.      }
  17. }
  18.   }
The program will stay in this loop for all choices. Hopefully, of choice is to exit the program or you are going to be here a looonnnggg time.
Apr 12 '14 #2
techboy
28
yes in C programming loop has two possibilities
1)true -i.e. any non-zero values are considered as true
2)false -i.e. only value zero is used to end the loop
Note:Its nice practice to use while(10)
but you must take care that you explicitly mention a break statement to avoid infinte loops
Apr 14 '14 #3
weaknessforcats
9,208 Expert Mod 8TB
The break statement I used was for the switch inside the loop. The loop is intended to be infinite so process always returns back to the menu.

There is nothing wrong in using infinite loops.
Apr 14 '14 #4
techboy
28
could you please elaborate why it is not wrong?
Apr 14 '14 #5
It is not wrong if you want to program to run always.
Apr 16 '14 #6
techboy
28
how is it sounds run always.No one wants the program to be forever it always has to some day terminate to give some results!
Apr 16 '14 #7
weaknessforcats
9,208 Expert Mod 8TB
Did you ever notice that Windows always runs?
Apr 16 '14 #8
techboy
28
No it would be honour if you can explain me ?
Apr 16 '14 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Dragonhunter | last post by:
Hello, I'm trying to response.write the infinity character. When I pull up the character map it says its code is U+221E (unicode I'm assuming?) for Times New Roman. I tried...
2
by: Russell Smith | last post by:
Timestamps support infinity. However if appears dates do not. When timestamps are cast to dates, there is no output. Is this an acceptable option or not? Below are a number of examples...
5
by: Peter Hansen | last post by:
I'm investigating a puzzling problem involving an attempt to generate a constant containing an (IEEE 754) "infinity" value. (I understand that special float values are a "platform-dependent...
2
by: Pierre Rouleau | last post by:
Hi all, When using Python 2.4.x on a Win32 box, marshal.loads(marshal.dumps(1e66666)) returns 1.0 instead of infinity as it should and does under Python 2.5 (also running on Win32 ). This...
12
by: horacius.rex | last post by:
Hi, I have a code that in some part of the program calculates 1/x for a lot of different x's. About 1 of 100 times x is equal to zero, so when I print the result I obtain inf. I wonder if there...
5
by: westhood | last post by:
In my program I must have some variables which values are infinity. It means the variable must be bigger than any integer. And if we add some to it, its value should still be infinity. I try...
14
by: Jim Langston | last post by:
The output of the following program is: 1.#INF 1 But: 1.#INF 1.#INF was expected and desired. How can I read a value of infinity from a stream?
13
by: kimiraikkonen | last post by:
Hello, I have an aritmetic calculation like this: First note that: i need a "timer" to get the value for value3. (however removing "timer" didn't differ) Dim value1 As Long Dim value2 As...
2
mageswar005
by: mageswar005 | last post by:
Hello sir, How can i pass the infinity values from one page to another page with out using post method. 1) I know in Get method some limitations are there.I think Only 1024 ...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.