Home • About Simply Explained  • Contact Us • 

hello
Questions answered by Mr Pramod S Nair  India   (Expert Rank: 2226) Member has an expert rating of 100+
 

What is the working of "for loop" in C programming?

Discuss this question

Question found in Programming
For Loop is an Iterative statement in the C language and it is usually used in scenarios where the number of repetitive cycles involved in the statement is known beforehand. For loops can also be used in situations where the number of iterations involved can't be predicted but such scenarios are handled more efficiently by looping structures like 'While' .

Now about the working of For Loops in C.

The syntax of a for loop in c language is :

for(counter initialization; conditional checking; action statement)
{
statements;
}

and here is a sample statement

for(i=1; i<10; i=i+1)
{
printf("HEHO\n");
}

Now let's analyze the sample statement given above.

The for(i=1; part of the loop initialises the value of i as 1. Now for the rest of the iterations this part of the statement is not taken in to the action. This part is executed only once.

The second part of the loop, i.e. i<10; is a conditional evaluation and the for loop will iterate as long as this condition is TRUE. Since the value inside i at this moment is 1 and it is indeed less than 10, this statement results in a TRUE during the first iteration and because of this the 'statements;' part of the loop inside the curly brackets ({}) i.e. printf("HEHO\n"); is executed. After the execution of this statement the action part of the loop statement is executed i.e. i=i+1). This increments the value of i by 1 and now i will contain 2. Now the program control is passed back to the second part of the loop, i.e. the conditional part and in this iteration too the condition return a TRUE ( since 2<10 is true) and the statements inside {} are executed. then the control is passed back to the action part of the loop statement and the value of i is increased by 1 to make it 3. These steps are repeated until the second part of the loop, i.e. the conditional evaluation returns a FALSE. In this case it returns false when the value of i becomes 10. and when it return false, the program control is passed to the statements coming after the curly brackets({}).

The above sample code prints the 'HEHO' nine times.

I think that the above explanation will be sufficient for you to grasp the idea of For loops in C language.

click to see other answers to this question
Discuss Answer

What is the most significant difference between the novel and movie in How To Kill A Mockingbird?

Discuss this question

Question found in Books & Authors
Some of the significant differences that can be found in the movie from the book are :

1. The absence of Atticus' sister, Aunt Alexandra in the movie. She was a prominent character in the book but wasn't there in the movie.

2. The role of Mrs. Dubose is played short in the movie.

3. The scene in which Atticus makes a quote on the topic of courage is entirely missing in the movie.

Check out the http://www.echeat.com/essay.php?t=29016 page for an article on this.

click to see other answers to this question
Discuss Answer

I have heard that you can tell the quality of champagne or sparkling white wine by the size of the bubbles, why is this so?

Discuss this question

Question found in Wines Of The World
It is true that the quality of champagne or sparkling white wine can be measured by the size of the bubbles up to a certain extent. The size of the bubbles is referred by the term "mousse" and typically a very fine mousse indicates a better quality of wine.

Small pinhead-size bubbles usually indicate the finest Champagne and wine with heavy or large bubbles are not considered of the highest quality. The heavy or big bubbles are called "oil de crapaud" (Eye of a Toad) in French.

Now lets have a brief look at how the size of bubbles can indicate the quality of the wine. The time and effort spent at the fermentation process involved in the making of a wine is a deciding factor in it's quality and this process involved can be identified by the bubbles produced in a particular wine.

Wines with little or no distinction are created by a simple carbonation process and this results in the large short lived bubbles. This is because due to the short duration of fermentation not much carbonation is done and so the dissolved amount of carbon dioxide will be very less.

If a particular make of wine is treated to a secondary fermentation process in a closed tank, (like Charmat process) it will result in a much better quality of wine. The amount of carbon dioxide dissolved in the wine is much greater in this case as a large amount of this gas is released in the second fermentation and since it is done in a closed tank much of the produced co2 is trapped in the wine. This produces medium sized bubbles and these bubbles are quite persistent.

Expensive and high quality wines are produced in a different method and in this method the secondary fermentation is done in the bottle itself. Traditional champagne is made with this process. This is a time taking and expensive process and it results in tiny, very long lasting bubbles.

So generally, the finer the bubbles the expensive is the wine.

Comments :
The reason I asked was because the last glass of Champagne I had the bubbles where as big as golf balls. Very good answer.

Cheers!


click to see other answers to this question
Discuss Answer

How long does it take to fly from New York to Maui in Hawaii?

Discuss this question

Question found in Tourism & Travel
A typical flight from John F. Kennedy International Airport, New York (IATA code JFK) to Hana Airport, Maui (IATA code HNM) will take about ten and a half hours. The distance between the two locations is about 7890 Kms (4900 Miles).

click to see other answers to this question
Discuss Answer

When did Liverpool win the milk cup?

Discuss this question

Question found in Football In General
Dear Liverpool, The Milk Cup is actually an international association soccer tournament which conducted for the Youth teams, and it is held annually in Northern Ireland. The tournament is categorized into 3 divisions based on age and they are 'Elite' for Under-19s in which National teams compete, 'Premier' for Under-17s in which both national and club teams compete and the 'Junior' level for Under 15s in which both national and club teams compete.

It is in 1988 that Liverpool F.C won this title by competing in the Premier Level by defeating Home Farm FC.

Now about the second Milk Cup. The Football League Cup or the League Cup English football competition was known as Milk Cup from 1982 - 1986 due to sponsorship reasons. During this period Liverpool F.C won 3 titles and the details are given below.

In 1982 Liverpool beat Tottenham Hotspur at Wembley Stadium
In 1983 Liverpool beat Manchester United at Wembley Stadium and
In 1984 Liverpool drew with Everton at Wembley Stadium and won the title by beating them in a rematch held at Maine Road.

click to see other answers to this question
Discuss Answer

In a CSMA/CD environment how many repeaters may be used between end systems?

Discuss this question

Question found in Computers Advanced
Since the CSMA/CD protocol requires a low propagation delay in order for working correctly, a optimal amount of repeaters placed between any two network nodes will be 4 or less. If the segment extends too long the propagation delay will increase and this will result in transfer errors.

click to see other answers to this question
Discuss Answer

What was Rosa Kiemeldavbbs weapon of choice in bond movie?

Discuss this question

Question found in Cinema In General
Colonel Rosa Klebb, a character from the novel 'From Russia With Love', was the head of Otdyel II, the SMERSH department of torture and death and her favorite and deadly weapon was her flick-knife shoes. Her black shoes had a flick to open knife tipped with poison and she can deliver death to the opponent by kicking with them.

click to see other answers to this question
Discuss Answer

What is there to do do in Portsmouth, New Hampshire?

Discuss this question

Question found in People & Places
Portsmouth, New Hampshire is the 3rd oldest city in the USA. Portsmouth, which was settled in 1623, is a historic seaport and is the home of the First Naval Shipyard. Sitting at the mouth of the Piscataqua River, this region is often referred as "The Seacoast" and it is a safe and major Tourist Spot. You can access this city by flying either to Manchester or Portland and it is only an hour of car ride away from these airports.

The city is actually small but offers a lot of historical places to visit. There are a lot of museums to visit around here. I am listing some of the Major Museums situated here :

1 . American Independence Museum at Exeter.

This museums features the story of the epical struggle for independence from the British. It also features a visit to the Ladd-Gilman House, a National Landmark Property, which belongs to the Gilman family and it is a very good historic destination.

2. The Strawbery Banke Museum at South End

Strawbery Banke Museum features an extensive collection of restored Colonial, Georgian, and Federal style architecture, saved from 1950s urban renewal by the efforts of historic preservationist like Dorothy M. Vaughan. Guests learn local history from guides dressed in era costume. Across the street from the museum are the riverside gardens and entertainments of Prescott Park. A visit to this place will let you experience life from the late 1600s to the 1950s as Strawbery Banke is rich with history (George Washington, Daniel Webster, John Paul Jones and John Hancock were all guests on this site)

3. Children's Museum of Portsmouth

An excellent center of visit for Children as they can learn about the arts and sciences through the exhibits at this museum.

There are also a good number of Historical houses, which will reflect you with the traditions and history of this place, like Wentworth-Coolidge Mansion, Wentworth-Gardner House, Jackson House, John Paul Jones House etc. They are also worth the visit.

Some other places of interest around the area are the Kittery Historical and Naval Museum, Water Country Water Park - an excellent water park with extensive rides, Red Hook Brewery,
Portsmouth Brewery, Port of Portsmouth Maritime Museum, Seacoast Science Center - A popular destination for families and students to learn about coastal environmental history, Sandy Point Discovery Center etc.

For a traveller with an open mind towards History and tradition this place offers a lot. For the casual traveller the good beaches, great food and nice people here will be enough for a relaxing visit.

click to see other answers to this question
Discuss Answer

Which German Christmas season figure punishes children who are naughty, not prayerful and don't know the catechism?

Discuss this question

Question found in Miscellaneous
In Germany One of the companions of Santa who is believed to punish children who are naughty is Knecht Rupprecht (Farmhand Ruprecht or Servant Ruprecht).

click to see other answers to this question
Discuss Answer

In which language is Christmas known as Nadolig?

Discuss this question

Question found in Cultures In General
As our expert 'Journo' stated in his answer, Nadolig is Christmas in Welsh. To know more about the traditions related to Welsh Christmas check out the below given link.

http://www.historic-uk.com/HistoryUK/Wales-History/WelshChristmas.htm

click to see other answers to this question
Discuss Answer
Page - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - 17 - 18 - 19 - 20 - 21 - 22 - 23 - 24 - 25 - 26 - 27 - 28 - 29 - 30 - 31 - 32 - 33 - 34 - 35 - 36 - 37 - 38 - 39 - 40 - 41 - 42 - 43 - 44 - 45 - 46 - 47 - 48 - 49 -
 Top of Page Terms and Conditions Privacy Disclaimer

© Simply Explained