what is difference between while and do while loop
1. In While loop the condition is
tested first and then the statements are executed if the condition turns out to
be true.
In do while the statements are executed for the first time and then the conditions
are tested, if the condition turns out to be true then the statements are
executed again.
2. A do while is used for a block
of code that must be executed at least once.
These situations tend to be relatively rare, thus the simple while is more
commonly
used.
3. A do while loop runs at least once
even though the the condition given is false
while loop do not run in case the condition given is false

4. In a while loop the condition is
first tested and if it returns true then it goes in the loop
In a do-while loop the condition is
tested at the last.

5. While loop is entry control loop
where as do while is exit control loop.

6. Syntax:

while loop :
while (condition)
{
Statements;
}
do while loop :
Do
{
Statements;
}while(condition);

Storage Class
'Storage classes' which are used to define the scope (visability) and life time of variables
and/or functions.

auto - storage class
auto is the default storage class for local variables.
{
}

int Count;
auto int Month;

The example above defines two variables with the same storage class. auto can only be
used within functions, i.e. local variables.

register - Storage Class
register is used to define local variables that should be stored in a register instead of
RAM. This means that the variable has a maximum size equal to the register size (usually
one word) and cant have the unary '&' operator applied to it (as it does not have a
memory location).
{
}

register int

Miles;
Register should only be used for variables that require quick access - such as counters. It
should also be noted that defining 'register' goes not mean that the variable will be stored
in a register. It means that it MIGHT be stored in a register - depending on hardware and
implimentation restrictions.

static - Storage Class
static is the default storage class for global variables. The two variables below (count
and road) both have a static storage class.
'static' can also be defined within a function. If this is done, the variable is initalised at
compilation time and retains its value between calls. Because it is initialsed at
compilation time, the initalistation value must be a constant. This is serious stuff - tread
with care.

extern - storage Class
extern defines a global variable that is visable to ALL object modules. When you use
'extern' the variable cannot be initalized as all it does is point the variable name at a
storage location that has been previously defined.
Source 1
--------

Source 2
--------

extern int count;

int count=5;

write()
{
printf("count is %dn", count);
}

main()
{
write();
}

Count in 'source 1' will have a value of 5. If source 1 changes the value of count - source
2 will see the new value. Here are some example source files.

Loop and storage class

  • 1.
    what is differencebetween while and do while loop 1. In While loop the condition is tested first and then the statements are executed if the condition turns out to be true. In do while the statements are executed for the first time and then the conditions are tested, if the condition turns out to be true then the statements are executed again. 2. A do while is used for a block of code that must be executed at least once. These situations tend to be relatively rare, thus the simple while is more commonly used. 3. A do while loop runs at least once even though the the condition given is false while loop do not run in case the condition given is false 4. In a while loop the condition is first tested and if it returns true then it goes in the loop In a do-while loop the condition is tested at the last. 5. While loop is entry control loop where as do while is exit control loop. 6. Syntax: while loop : while (condition) { Statements;
  • 2.
    } do while loop: Do { Statements; }while(condition); Storage Class 'Storage classes' which are used to define the scope (visability) and life time of variables and/or functions. auto - storage class auto is the default storage class for local variables. { } int Count; auto int Month; The example above defines two variables with the same storage class. auto can only be used within functions, i.e. local variables. register - Storage Class register is used to define local variables that should be stored in a register instead of RAM. This means that the variable has a maximum size equal to the register size (usually one word) and cant have the unary '&' operator applied to it (as it does not have a memory location). { } register int Miles;
  • 3.
    Register should onlybe used for variables that require quick access - such as counters. It should also be noted that defining 'register' goes not mean that the variable will be stored in a register. It means that it MIGHT be stored in a register - depending on hardware and implimentation restrictions. static - Storage Class static is the default storage class for global variables. The two variables below (count and road) both have a static storage class. 'static' can also be defined within a function. If this is done, the variable is initalised at compilation time and retains its value between calls. Because it is initialsed at compilation time, the initalistation value must be a constant. This is serious stuff - tread with care. extern - storage Class extern defines a global variable that is visable to ALL object modules. When you use 'extern' the variable cannot be initalized as all it does is point the variable name at a storage location that has been previously defined. Source 1 -------- Source 2 -------- extern int count; int count=5; write() { printf("count is %dn", count); } main() { write(); } Count in 'source 1' will have a value of 5. If source 1 changes the value of count - source 2 will see the new value. Here are some example source files.