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

  • Update draw.io on Windows
  • Install RAPTOR Avalonia on CentOS
  • Download RAPTOR Avalonia Edition on Windows
  • npm doctor command
  • Build & Run CLion Project
  • Create New CLion C Project on Windows
  • Configure CLion Toolchains on Windows
  • Launch CLion IDE on Windows
  • Activate CLion IDE
  • CLion IDE for C/C++ Development

Back to Top

Links

  • Contact
  • Privacy Policy
  • Cookie Policy

www.TestingDocs.com