Search
 
SCRIPT & CODE EXAMPLE
 

C

Relational Operator in C language

#include<stdio.h>
int main(){

int a = 20;
int b = 10;
int c;

// == operator
if(a == b){
 printf(“a is equal to b
”);
}else{
 printf(“a is not equal to b
”);
}

// > operator
if(a > b){
 printf(“a is greater than b
”);
}else{
 printf(“a is not greater than b
”);
}

// < operator
if(a < b){
 printf(“a is less than b
”);
}else{
 printf(“a is not less than b
”);
}

// != Opertor
if(a != b){
 printf(“a is not equal to b
”);
}else{
 printf(“a is equal to b
”);
}

// >= orperator
if(a >= b){
 printf(“a is greater than or equal to b
”);
}else{
 printf(“a is not greater than or equal to b
”);
}

// <= operator
if(a <= b){
 printf(“a is less than or equal to b
”);
}else{
 printf(“a is not less than or equal to b
”);
}

}
Comment

Relational Operators in c

// Working of relational operators
#include <stdio.h>
int main()
{
    int a = 5, b = 5, c = 10;

    printf("%d == %d is %d 
", a, b, a == b);
    printf("%d == %d is %d 
", a, c, a == c);
    printf("%d > %d is %d 
", a, b, a > b);
    printf("%d > %d is %d 
", a, c, a > c);
    printf("%d < %d is %d 
", a, b, a < b);
    printf("%d < %d is %d 
", a, c, a < c);
    printf("%d != %d is %d 
", a, b, a != b);
    printf("%d != %d is %d 
", a, c, a != c);
    printf("%d >= %d is %d 
", a, b, a >= b);
    printf("%d >= %d is %d 
", a, c, a >= c);
    printf("%d <= %d is %d 
", a, b, a <= b);
    printf("%d <= %d is %d 
", a, c, a <= c);
  
//Output

//5 == 5 is 1
//5 == 10 is 0
//5 > 5 is 0
//5 > 10 is 0
//5 < 5 is 0
//5 < 10 is 1
//5 != 5 is 0
//5 != 10 is 1
//5 >= 5 is 1
//5 >= 10 is 0
//5 <= 5 is 1
//5 <= 10 is 1 
    return 0;
}
Comment

logical operators in c

Logical Operators: 
They are used to combine two or more conditions/constraints or to complement 
the evaluation of the original condition under consideration. They are 
described below: 
 

Logical AND operator: The ‘&&’ operator returns true when both the conditions 
under consideration are satisfied. Otherwise it returns false. For example, a
&& b returns true when both a and b are true (i.e. non-zero).

Logical OR operator: The ‘||’ operator returns true even if one (or both) of
the conditions under consideration is satisfied. Otherwise it returns false. 
For example, a || b returns true if one of a or b or both are true 
(i.e. non-zero). Of course, it returns true when both a and b are true.

Logical NOT operator: The ‘!’ operator returns true the condition in 
consideration is not satisfied. Otherwise it returns false. For example, 
!a returns true if a is false, i.e. when a=0.
Comment

Logical Operator in C language

#include<stdio.h>
int main(){
  A = 5;
  B = 10;
if((A == 5) && (B < 11)){
 printf(“Both conditions are ture”);
}

if(!(A==5)){
 printf(“A is not equal to 5”);
}

if((A>=3) ||(B<=9)){
 printf(“min any one condition is true”);
}

}
Comment

PREVIOUS NEXT
Code Example
C :: redis service 
C :: snprintf c 
C :: while loop in c 
C :: print the name of a file c 
C :: What should main() return in C? 
C :: scopes in c 
C :: size of operator in c language 
C :: logical operators in c 
C :: boolean operators in c++ 
C :: getchar declaration in c 
C :: c convert float to int 
C :: lxde automatic login 
C :: Number 10 
C :: count number of items using delimiter 
C :: como somar em C 
C :: amazon kinesis disaster recovery 
C :: parcel-bundler include image files 
C :: Uri/Beecrowd problem no - 1151 solution in C 
C :: translator program in c 
C :: reading arrays from stdin c 
C :: bc1q9rfht42zayr3yvxqjw8tm6v3tkwl93t35gegxl 
C :: convert c code to c online 
C :: passing an array to a function 
C :: sscanf and sprintf in c 
C :: String insertion into another string 
C :: /usr/bin/mandb: fopen /var/cache/man/7935: Permission denied 
C :: can we use special characters in switch case in c 
C :: else if statement in c 
C :: how to push node using linked list c 
Dart :: listview.separated flutter 
ADD CONTENT
Topic
Content
Source link
Name
4+7 =