Logical Operators in C Language

Logical Operators in C Language:

(1) Logical Operators are used for assigning values to variables

(2) Sample C language code and its output, as shown:

Sample C language code for logical operators
#include <stdio.h>
#include <conio.h>
// Logical Operators in C Language
intmain()
{
int x;
int y;
x = 5;
  y = 7;
  // Returns 1
printf(“Return Value: %d\n”, x > 3 && x < 10);
  // Returns 0
printf(“Return Value: %d\n”, x > 3 && x < 5);
  x = 5;
  y = 2;
  //Returns 1
printf(“Return Value: %d\n”, x > 3 || x < 7);
  //Returns 0
printf(“Return Value: %d\n”, y > 4 || x < 1);
  x = 5;
  y = 11;
  // Returns 0
printf(“Return Value: %d\n”, !(x > 3 && x < 10));
  // Returns 1
printf(“Return Value: %d\n”, !(y > 3 && y < 10));
getch();
return 0;
}

(3) After that go to the “Build” menu and select the “Build” option for publishing the code as shown.

click on build for logical operator code unit

(4) After building the code, press the “Run” button, as shown.

Press the run button for Logical Operators in C

(5) After pressing the “run” button, the output screen is opened, as shown.

Logical Operators in c output screen opened
Logical OperatorsOperations
&&Logical AND operator
||Logical OR Operator
!Logical NOT Operator

Use of REVERSE Function in SQL
Use of LOWER Function in SQL
Use of RIGHT Function in SQL
Use of DATALENGTH Function in SQL
DATALENGTH (Transact-SQL)– Microsoft Docs

Leave a Reply