What is a Boolean in the sense that how can you use it in code and give an example please | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What is a Boolean in the sense that how can you use it in code and give an example please

6th May 2020, 6:49 PM
Emmanuel Abraham
2 Answers
+ 1
Boolean has a value either true or false. Ex: in c++, bool b= true; b=false; You can use it according to your requirements.. As other data types.. Ex: b=false; if(num%2==0) b=true; if(b) printf("even"); else printf("odd") ;
6th May 2020, 8:44 PM
Jayakrishna 🇮🇳
0
#include <iostream> using namespace std; int main() { int num=1; while(num>10?false:true ) { cout<<num++<<"\n"; } return 0; }
6th May 2020, 7:34 PM
Dasarath Singh