answersLogoWhite

0


Best Answer

when use for loop user can assign the value of the variable inside the loop, while checking the condition. but in while loop he has to assign it out side of the loop. like

for loop: for(i=5, n=2; i<=8; i++)

{ n=n+5;

}

while loop: int i=5, n=2;

while(i<=8)

{ n=n+5;

i++;

}

User Avatar

Wiki User

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

Wiki User

11y ago

For Lopp;

for Lop is Used For The Specific execution of Our Programm or statements

and we Should initialized,condition and Increment and decrement operator should be declare in for body

e.g

for (intialization;condition;increment or decrement)

while lop:

The While lop use when we dont Know How many time we want execute the set of statemen or statements and in While Body we put only condition.

e.g

while (logical condition)

BY MANSOOR ULLAH

BS comp AWK university mardan pk

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is the difference between while and for loop in c programming?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What is the Difference between while and do while?

Both are programming commands. A do/while loop will execute at least once. A while loop may not execute at all.


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 the difference between do while and do until loop in vb programming?

Do while and Do until are interchangeable, and they take the opposite condition. Do While executed the body of the loop while (condition=true), and Do until executes body of loop until (condition=true). For example, if I was doing a Loop to say, while the check box is checked, display a message box (Never do this btw, it's just an example) I could either say Do While (MyCheckBox.Checked = True) Loop or Do Until (MyCheckBox.Checked &lt;&gt; True) Loop


What is the difference between if and while loop?

Easy: if-else is not a loop; while, for and do-while are loops.if-else just run once, but do-while run many times.


Difference between for and while loop not in syntactically?

Well 'while' goes like this: while (condition) statement 'for': for (initialize; condition; after-each-loop) statement


Is a while loop or a for loop faster?

No difference.


What is a loop type?

A Loop is a programming language construct that instructs the processor to repeat a sequence of operations a number of times until a specific condition is reached. There are different types of loops. They are: * for loop * while loop * do while loop


What is the difference between while loop and for loop in oracle?

You mean PL/SQL? Well, they are different things, read the manual for details.


What is main different between do while and while?

If you want to execute a statement which is in while loop at least one time you can use do- while loop. this is why because initially first statements will be executed then condition will be checked. but in case of while first condition will be check then statements will be executed


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.


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 difference between do and while loops in c?

the main difference b/w do and while loops is that do loop will run atleast once even if condition is not satisfied but while loop will not execute even once if condition is not satisfied . this is bcoz in do loop condition is checked after one execution but in while condition is prechecked.