answersLogoWhite

0

How does the for loop work in c?

Updated: 8/10/2023
User Avatar

Wiki User

15y ago

Best Answer
  • For loop is "Counter controlled loop" i.e. a counter or control variable is used to process the for loop , as discussed in earlier chapters.
  • For loop is an "Entry controlled loop" i.e. the condition to iterate the loop must be check at the starting of the loop and loop body will not execute if the condition is False. Source website:

http://codedunia.in/c-language/for-loop-in-c-programming.php

User Avatar

Wiki User

12y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

15y ago

for(initialization; condition; end_action) {

code

}

* initialization - used to initialize variables (usually something like i = 0)

* condition - boolean expression; loop continues while expression is met

* end_action - action to perform at the end of the loop (usually something like i++)

* code - code to repeat Note that any of the above sections can be empty:

for(;;){}

This is a valid code block which will do nothing and never finish.

This answer is:
User Avatar

User Avatar

Wiki User

13y ago

Hi,

Nested loop is loop inside the loop.

example

for(i =0;i<0x12;i++)

{

for(j= 0;j<0x20;j++)

{

// sample of nested loop

}

}

This answer is:
User Avatar

User Avatar

Wiki User

12y ago

No limit, you may have as many loops (nested or separated) as you need.

You can use any or all of these:

1. while (exp) stmt

2. for (exp; exp; exp) stmt

3. do stmt while (exp);

4. LABEL; stmt ... goto LABEL

5. recursion

This answer is:
User Avatar

User Avatar

Wiki User

8y ago

For loop, while loop, do while loop and goto loop.

This answer is:
User Avatar

User Avatar

Wiki User

12y ago

In C: when inside a loop there is another loop

In other languages: when inside a loop there is another loop

This answer is:
User Avatar

User Avatar

Wiki User

13y ago

This is used to enable the computer to execute a particular piece of code as many times as required without increasing the complexity of the source code, making it easier to read and maintain

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How does the for loop work in c?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Which loop is also called an exit-condition loop in C programming?

The do while loop is also called an exit condition loop in c, c++, and java.


In C which loop is embedded within another loop?

The nested loop.


Is do while loop in c is exit controoled loop?

yes


What is odd loop in 'C' program?

odd loop means at least the loop execute once.


What is the definition of 'nested' in C programming?

In C a structure within a structure is called nested. For example, you can embed a while loop in another while loop or for loop in a for loop or an if statement in another if statement.


Do-while loop in c?

Available.


Does 'for loop' works in C plus plus?

In C++, a for loop is structured as follows: for( int index = 0; index &lt; 10; ++i ) { //do something }


What are the differences between Do While and For loops in C?

In short, a for loop declares an variable and assigns it a value, has an argument, and has an update. A while loop only has an argument. More Detail... in C++, which is very close to C an example while loop is; while(i


What is the difference between a do while loop and a for loop in c?

the counter variable cannot be initialized in while loop before entering into the block.


What is difference between select Case statement and nested loop in c programming in UNIX?

UNIX has no bearing on the C language; it is cross-platform. There is no select/case in C, you probably meant switch/case. However, a switch/case is a conditional jump while a nested loop is a loop within a loop. Besides the C language they have nothing in common with each other.


What is the structure of the DNA loop?

A to T, T to A, G to C, C to G


What are the examples of different type of loop structure c net?

// Examples of five Loop structures in C# // Each one iterates over the characters in a string, and writes // them to the Console. string s = "This is a test"; // For Loop for (int i=0; i&lt;s.Length; i++) Console.Write (s[i]); // Foreach Loop foreach (char c in s) Console.Write (c); // While Loop int i=0; while (i&lt;s.Length) Console.Write(s[i++]); // Do Loop int j=0; do Console.Write(s[j++]) while j&lt;s.Length; // Spaghetti Code int k=0; loop: Console.Write(s[k++]); if (k&lt;s.Length) goto loop;