473,395 Members | 1,488 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,395 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 1536
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
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.