TODAY JAVA SCHOOL

In java school, programming, design, computer general knowledge, web application, software, web services, social media, digital marketing, oops, concept of programming language, oops feature, console media, graphics medium, first programming, c, c ++ , Java, PHP, SQL, MySQL, HTML, HTML_5, J_query, JavaScript, Bootstrap, Framework, images with logos, examples, shared and explained.

https://www.amazon.in/b?node=26373545031&linkCode=ll2&tag=1234567801cdb-21&linkId=3b9882431b00409b44141e0344b35a15&language=en_IN&ref_=as_li_ss_tl

Breaking

Wednesday, 6 May 2020

Boolean In C Language | Boolean Expression In C Language | Boolean Types In C Language | Boolean Datatype In C Language

Boolean In C Language

C Language Boolean is a data type that contains two types of values, i.e., 0 and 1.

 Basically, the bool type value represents two types of behavior, either true or false. Here, '0' represents false value, while '1' represents true value.


download the image of boolean expression in c language

Fig: Boolean In C Lnaguage 


In C Boolean, '0' is stored as 0, and another integer is stored as 1. We do not require to use any header file to use the Boolean data type in C++, but in C, 

we have to use the header file, i.e., stdbool.h. If we do not use the header file, then the program will not compile.

Syntax


bool variable_name;

Program Of Boolean

  #include <stdio.h>  
  #include<stdbool.h>  
  int main()  
   {  
   bool x=false; // variable initialization.  
    if(x==true) // conditional statements  
    {  
   printf("The value of x is true");  
    }  
    else  
     printf("The value of x is FALSE");  
    return 0;  
    }  

Output:

The value of  x is FALSE

Boolean Array

 we create a bool type array. The Boolean array can contain either true or false value, and the values of the array can be accessed with the help of indexing.

  Program Of Boolean Array


   #include <stdio.h>  
   #include<stdbool.h>  
   int main()  
   {   
   bool b[2]={true,false}; // Boolean type array  
   for(int i=0;i<2;i++) // for loop  
  {  
   printf("%d,",b[i]); // printf statement  
   }  
   return 0;  
   }  

Output:

1,0

No comments:

Post a Comment