While and for loop

sir plz solve my one doubt ,if for loop is equivalent to while loop then how I will differentiate when to use for and when to use while in a question?

there is not specific rule which one you have to use because both are same thing

if you know only one loop you can solve every question

i prefer for loop most of the time
because in while loop the increment condition has to written inside loop and something i forgot it which cause run time error

but while is also good when there is simple condition because it is simple
something you have run a function n times
then you can use while

while(n--)
 funciton();

if you have more doubts regarding this feel free to ask
i hope this helps
if yes hit a like :heart:: and don’t forgot to mark doubt as resolved :grinning:

1 Like

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.

1 Like