TestingDocs.com
    Software Testing website
    • Automation
      • Selenium
      • JBehave Framework
    • Tutorials
      • MySQL Tutorials
      • Testlink
      • Maven
      • Git
    • IDEs
      • IntelliJ IDEA
      • Eclipse
    • Flowcharts
      • Flowgorithm
      • Raptor
    • About

    C Tutorials

    C Logical Operators

    Overview

    In this tutorial, we will learn about C logical operators. Logical operators are used to combine multiple logical expressions and evaluate them to a single logical value i.e true or false

    C Logical Operators

    C language has three logical operators, they are as follows:

    C Logical 

    Operator

    Operator  Symbol Description
    and Operator && The and operator is a binary operator. It requires two boolean conditional expressions that should be evaluated to be either True or False.

    The and returns True If both the conditions are True. Otherwise, it will return False.

    or Operator  || The or operator is also a binary operator. It requires two boolean conditional expressions that should be evaluated to be either True or False.

    The or returns False If both the conditions are False. Otherwise, it will return True.

    not Operator ! The not operator is a unary operator. It requires only one boolean conditional expression.

    The not negates the given condition. It will return True if the condition is False. It will return False if the condition is True.

    Example

    The Boolean data type is declared in the stdbool.h header file. We need to include the header file to work with the bool data type and boolean constants like true, and false.

    /**
    **********************************
    * Program Description:
    * C Logical Operators
    * Filename : logicalOperators.c
    * C Tutorials – www.TestingDocs.com
    *************************************
    */
    #include<stdio.h>
    #include<stdbool.h>
    int main()
    {
    int number = 15;
    // C Logical Operators
    bool bExpr = (number > 10) && (number < 25);

    printf(“%d \n”,bExpr);
    printf(“%d \n”,!(number > 10));
    printf(“%d \n”,!(number > 10) || (1 == 1));
    return 0;
    } // end main

     

    C Logical Operators

     

    Related Posts

    C Language Characteristics

    C Tutorials /

    C Language Characteristics

    C Source Code .c File

    C Tutorials /

    C Program Files & Formats

    GNU Compiler Collection GCC

    C Tutorials /

    C Compilers

    C Pointers

    C Tutorials /

    C Pointers

    C Tutorials /

    C Two-Dimensional Arrays

    ‹ C Programming Statements› C if-else Statement

    Recent Posts

    • ChatGPT Subscription Plans
    • Stellar Converter for Database
    • Stellar Log Analyzer for MySQL
    • Stellar Repair for MySQL
    • ChatGPT Capabilities
    • How to secure your SQL Database: Tips and Tricks
    • ChatGPT4 Conversational AI Features
    • Shaping the Future of Development: Exploring Key Trends in Software Engineering
    • Improving Java Performance with Multithreading
    • Open-source Vector Databases

    Back to Top

    Links

    • Contact
    • Privacy Policy
    • Cookie Policy

    www.TestingDocs.com