top of page
Search

Why and when to use a for loop versus a while loop in programming?

Typically, you would use a for loop when you know how many times you would like the loop to run. An example would be Topic #1 of this discussion post. You know the loop needs to run to number 100, therefor it is a for loop. A while loop is run until a condition is met and functions a lot like "if" statements, or at least uses the same conditional structure as the "if" statements. It should also be noted that the while loop is typically used when the number of times the loop needs to run is not known.


Example clipped from here (Links to an external site.) www.cs.utah.edu



 
 
 

Recent Posts

See All
Assessing PCI DSS Requirement 8

Assessing PCI DSS Requirement 8: Secure Passwords for Organizations Processing Credit Card Data Credit card information is a top target...

 
 
 
The Importance of Risk Management

The Importance of Risk Management in Cyber Security Assessments and Audits In today's digital age, the risk of cyber-attacks and data...

 
 
 
The Importance of Auditing

The Importance of Auditing: A Comparative Analysis of Internal and External Audits IT auditing is the process of assessing a company's...

 
 
 

Comments


bottom of page