Can anyone tell me what was bool for/function? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Can anyone tell me what was bool for/function?

13th Dec 2016, 5:43 AM
Charlon Jios
Charlon Jios - avatar
3 Answers
+ 5
book (short for boolean) stores either true or false as its value. It's used to create flags, that say whether something has occurred or not. The naming conventions for them usually follow the pattern of isX (Ex: isActive). Here's an example of how to use one: //Linear search of an array for (int i = 0; i <= ARR_SIZE; i++) { if (arr[i] == wantedVal) { isFound = true; location = i; break; } } if (isFound) cout << wantedVal << " found at position " << location << endl; else cout << wantedVal << " was not found..." << endl;
13th Dec 2016, 7:44 AM
Tamra
Tamra - avatar
+ 2
bool means boolean it is data type to store true false
13th Dec 2016, 6:18 AM
Sandeep Chatterjee
+ 1
thanks..but i still dony know how to use it correctly
13th Dec 2016, 6:36 AM
Charlon Jios
Charlon Jios - avatar