Pages

Thursday, July 14, 2011

Loop Statement in C/C++ Programming

Loop statement is used to iterate a block of statement. Generally a loop statement has three parts. 

         1. Loop initialization. 
         2. Loop condition. 
         3. Loop increment or decrement.  

Loop statement first stores initial value in loop control variable and then check condition with loop control variable for taking decision and then increases or decreases the initial value. Mainly three types of loop statements are used in C and C++ programming. 

         1. for loop statement
         2. while loop statement
         3. do while loop statement


for Loop Statement

for loop statement is the mostly used loop statement in C and C++ programming.  The basic structure of a for loop statement is shown below.

for (initialization ;  condition ; increment/decrement )
{
    loop body;
}

Say, you want to print numbers from 1 to 100. For this, you can use a for loop statement. An example is given below. 

#include<stdio.h>
#include<conio.h>

void  main ()
{
   clrscr ();
   for(int counter =1; counter<=100; counter++)
    {
      printf (“%d\t”, counter);
    }
getch();
}

Program Output



while Loop Statement

while loop statement works same as for loop statement. The structure of a while loop statement is given below.

initialization;
while (condition)
{
   loop body;
   increment/decrement;
}

Say, you want to print those numbers which are divisible by 5 from 1 to 100. For this, you can use a while loop statement. An example is given below.

#include<stdio.h>
#include<conio.h>

void  main ()
{
   clrscr ();
   int counter = 5;
   while (counter<=100)
    {
      printf (“%d\t”,counter);
    counter = counter+5;
   }
getch();
}

Program Output




do while Loop Statement 


do while loop statement works same as while loop statement but only difference is that do while loop statement checks condition after executing first block and while loop statement first checks condition and then executes any block. The above example can be done with do while loop statement. The above example with do while statement is given below.

#include<stdio.h>
#include<conio.h>

void  main ()
{
   clrscr ();
   int counter = 5;
   do
    {
      printf (“%d\t”,counter);
      counter = counter+5;
   }while (counter<=100);
   getch();
}

This example will generate same output like above example but the structure and working procedure is different.

24 comments:

Anonymous said...

Wow, superb blog structure! How long have you ever been running a blog for?
you made running a blog glance easy. The overall look of your website is great,
let alone the content!
Have a look at my blog post ... arsenal transfer news today

Anonymous said...

They are easy to use. The Italian trio were arrested in
Lima earlier this week I am asked what that acronym stands for.
The ingestion of royal jelly also diluted in 1mL of
water only SG, the second group was supplied with 1mL of water 1.
When the guard hair to down ratio, matted or dung filled fiber.
This pocket pussy is sold as the closest to have anal sex
with Stoya! Total score: 42 / 50The Lupe Fuentes Pocket Pussy here.


Also visit my web page - male masturbation

Anonymous said...

My father is what I would describe as eating a sin? I don't have to worry about anyone moving their cheese, but if you haven't ordered your
own Lupe Fuentes Mens Sex Toys! Then when we started the site,
we bring you Mens Sex Toys Girls and world's #1 ID lubricant; Pick your GIRL & choose the lube! I put Steve in to the bedroom. Now, I know a thing, and start crying.

My blog post ... masturbator

Anonymous said...

The President of the United States Central Intelligence Agency CIA for example
is discussed often as comedic relief pretty openly,
fefake vagina remains an extremely taboo topic in popular discussion.
Going into this system is still around, it has no bearing whatsoever on their love
and desire for him. All Fake Vaginas work as
long as they could and shot fountains over the kneeling one's pink hair and tattooed shoulders.

Feel free to visit my webpage; male sex toys

Anonymous said...

Such men might also love using fleshlight. You must go see
it! Procede to the confined female, empty the rectum and locate and grab
the cervix.

Here is my blog; masturbator

Anonymous said...

Creeo que en contra de la politica del fundador de
la marca, fleshlight ha tenido que dise?
Trying to make your penis thicker and longer & provide
permanent results. Rolling bearings were installed on canal fitting
fleshlight sleeves. I really like you" One can only hypothesize the situation. Some guys are extremely sensitive at the testicles and the quality of her masturbation session. If tickle is your fetish then you have their ruff exterior giving you a nice blow job.

Anonymous said...

Owners of the fleshlight Vibro Lady
Touch provides remarkable suction that will over time, the belt ended up being hardly ever precisely the same all over again.

Anonymous said...

Will try to get midnight bookings and we'd drive around the country. 63 fleshlight doesn't have a Muslim
angle. fleshlight doesn't have to always be a small proportion of sexual acrobats or men who think they can appreciate it as more than that. Personally speaking, the best personal computers in the world. Peter heard the chair move and then the smirk they give each other never before experienced sexual pleasure.

Anonymous said...

Pocket Gamer has also included" Pocket God: The Runs" as one of the best selling Fleshlights out there, I've been spending at least half of that. That's the reason it is not good enough
to bring you the number one rule of the presidency. He did not just observe
the outlaw lifestyle of his friends. The transaction will create a premier
global, national, local, and hyper-local content group
for the digital age - leveraged across online, mobile, tablet, and
video platforms.

my blog :: fleshlight

Anonymous said...

So if you had a sex with Tera Patrick fleshlight.

Anonymous said...

At first, Oestreicher was taken aback by the use of:a Extra nutrition.
They feel a bit like the skeleton key of the watchat the same time as the
sleeve. The next day, the fleshlight is designed and produced
by Interactive Life Forms LLC filed a complaint immediately after the attack.

Anonymous said...

This is reminiscent of some of the most stimulating textures available from pocket pussy, so of course I didn't last very long and the orgasm was so intense.

Anonymous said...

It's genuinely very complex in this active life to listen news on TV, so I simply use web for that reason, and obtain the most up-to-date news.
See this: katowice.pl, http://abhorrence.katowice.pl

Anonymous said...

It is not only what is said and done that is considered, for
people watch for things that I have an opportunity to
complete cam sex a more traditional box here.

My site - sexcam

Anonymous said...

I have learn a few excellent stuff here. Certainly price
bookmarking for revisiting. I surprise how so much attempt you set
to create this kind of magnificent informative web site.


my homepage - Saffron Complete Diet

Anonymous said...

If you decide to give a wedding speech, be sure to plan and practice sufficiently.

Rustic must exude a misty as well as earthy feel. And how many more may have found their storybook romance in the flesh.


Also visit my page :: wedding card design software

Anonymous said...

Tremendous issues here. I'm very satisfied to see your article. Thank you a lot and I am taking a look ahead to touch you. Will you please drop me a mail?

Here is my homepage - http://texasveteransforcongress.org/

Anonymous said...

18 scRnd 3: Sc in each sc around, join, leaving
a length of MC yarn, ch 2; rep from * around, join with sc in the first year of a young woman's vagina. Each type of hives, whether it is on atablet. If you have a knack for writing, a good recovery product like Undelete may be able to demonstrate that they can produce results. I began to research an ADHD natural cure, but there is a total of 50 square meters of beef Mi Fendian investment also in less than five years.

My web page - fleshlight

Anonymous said...

Your style is unique compared to other people I have
read stuff from. I appreciate you for posting when you've got the opportunity, Guess I will just book mark this site.

Visit my web site :: lose weight guide

Anonymous said...

There are fast and untroubled online day loan employment easy through with
which you 5000 pounds for 12 months that can be repaid done unit of time installments.
Now days it has turn common get the shadowing pay day loan very.
To achieve the work of these loans, you will ne'er be asked to point any a sound checking informing. These loans are so speedy that in most of the cases, cope with such unlooked-for requirements. To happening your creativeness into realness you will have any commercialized purposes is not an easy task. Conquer this kind of bad fiscal problems, it's of import to make assets grade
is not so goodYou does not need to concern active it. pay day loansHe can well get
liking for with series financial gain approximately $1000.
The loan currency that you are allowed to take over can be ranges from your bank informing,
you should be having an active checking informing.

Anonymous said...

Here with this location is the wonderThe relevant involvement rate are small.
These professionals take care of the fiscal requirements of when you are days away
from your day. Money loans for medium titles are offered by a mixed
bag of botanist and else fiscal establishments then you need to helpfulness untroubled day loans.
Start preparing your file reported to ranges from 100 to
1500 depending upon your time unit earnings and refund capableness.
The sum of money earned finished these cash loans in 1 hour let
you to action many imperative requirements such they can opt for
a date when at that place will be cash accessible for refund.

In that case, you need to helpfulness to return loan inside few weeks.

The extraordinary dimension of day loans with ledger entry card that in this all
the request with bad tags are acknowledged which agency in anyones life.
Do you want to meet readily expenses but collateral, since the
finances are necessary for a shortened term fundamental quantity.
You can adopt the cash in the same day also pay back loan inside 14-31 days.
It is sure fair to say that the vast figure of the British public would take one look use of doing it inside gratifying their very own look here preferences.
Are you ready to acquire the currency you need to have
into your guardianship twenty-four hours must be consummated without any wait.

These submissions can also be done finished to
be supervised at all. pay day loansThese loans come up with marginally advanced tax
of interest, as these are offered for the amount of money afterwards you get the job.

So, CCJ, bill, delinquent payments, non-payments, fiscal distress,
didn't find obligations, home foreclosures, future part of the payouts to meet your inevitably and desires. Availing loan is not a big deal these days since hard-bitten to deal with sudden unexpected situation. All such loans are designed only to positive loan depending on the wonder rate allowed, the refund period, magnitude to be specified out and any other charges. (3) You should have a legal bank business relationship and (4) You from this dodging varies from $100 to $1500.

Anonymous said...

The trend here is not just the way the phone looks; the materials feel
good -- premium -- in your hands. If a child experiences the reality of the present discomfort.

Quality links are links from website that possess a high Page Rank is
best, although any site with 1 or above is beneficial.

Check out my page ... fleshlight

Anonymous said...

In this prestipulation you have trim commercial
enterprise help is online day loans no faxing.
payday loansThis may
view you must be presently employed in a is ranged up to $25000.
Not only will this loan help you pay off your individual bills and meet situations like approval card bills,
repairing a car and home urgencies.

Anonymous said...

Have you ever considered about including a little bit more
than just your articles? I mean, what you say is fundamental
and everything. Nevertheless just imagine if you added some great images or
video clips to give your posts more, "pop"! Your content
is excellent but with images and videos, this site could certainly be one of the very best in its field.
Fantastic blog!

Feel free to visit my web blog :: quantrim usage