Differentiate between For loop and While loop. Mention their syntaxes.
Answers
Answered by
1
Answer:
for loop is loop which is used to itrate the elements any list or any array(in java) and print them accordingly
example of syntax of for loop in python
i=0
for (i <=10):
(indent) print ("Hello world")
(indent) i++
example of syntax of for loop in java
for(int i=0;i<=10;i++){
(indent) System.out.prinln("hello world")}
while loop is the loop which can not itrate the elements any containers
example of syntax of while loop in python
while (true):
(indent)print("hello world")
example of syntax of while loop in java
while (true){
System.out.println"hello world"}
these both are infinite while loops
Similar questions
Computer Science,
1 month ago
English,
1 month ago
Hindi,
1 month ago
Math,
3 months ago
Physics,
3 months ago
History,
9 months ago
Political Science,
9 months ago
English,
9 months ago