whats the use of flag in coding

closed account (1Ujz3TCk)
please tell
In a programming context, "flag" means the same thing as "boolean". Hence, a flag value is a boolean value: true or false.

Hope this helps.
an example is like
1
2
3
4
5
6
7
8
9
10
11
bool isTrue=true; // set true so it enters the loop
int number=0;
while(isTrue)
{
    number+=1;
    if(number ==5)
    {
         //change flag to false so the loop doesn't execute any more
         isTrue=false;
    }
}
Last edited on
Topic archived. No new replies allowed.