What is a boolean flag?

what is a boolean flag and how its work?

Hey @rahulkumar0116 Sorry for the delay in response.boolean flag is a boolean variable which means flag will store only true or false and the variable name which is given to it is names as “flag” that’s the technical meaning of boolean flag. Now As you can see in the code we have made flag = false when the condition of prime number is not satisfied that means whenver n is divisible by number except fro 1 and itself. So flag = false means n is not a prime number(flag = false) but if there is not a number which divides n that means n is prime and since we have given initially that flag = true; So flag will remain true and this will tell us that n is prime (flag = true).

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.