Amaresh Satapathy
Query: 22 / Answer: 28

09th Feb 2017 .

what is the difference between for and foreach?


Answers

Arpita Panigrahi
Query: 16 / Answer: 18

09th Feb 2017 .

for is expressed as follows:
 
for (expr1; expr2; expr3)
 
statement
 
The first expression is executed once at the beginning. In each iteration, expr2 is evaluated. If it is TRUE, the loop continues and the statements inside for are executed. If it evaluates to FALSE, the execution of the loop ends. expr3 is tested at the end of each iteration.
 
However, foreach provides an easy way to iterate over arrays and it is only used with arrays and objects.

  •  Information
  • About Forum

    This educational forum is produly developed by betaQsolutions-A leading software company in Odisha. This forum is developed to discuss the educational topics only betweeen the Students, teachers, Parents & Experts. Topic related to Career, Syllabus, Subjects, Questions, Exams etc are allowed to discuss here.

  • Statistics

    Total topics 43 • Total Query 1115 • Total members 247 • Total Answered 1286