LOGICAL OPERATORS IN C
LOGICAL OPERATORS SYMBOLIC TABLE
OPERATOR
|
MEANING OF OPERATOR
|
&&
|
Logical And
|
||
|
Logical Or
|
!
|
Logical Not
|
LOGICAL OPERATORS EXAMPLES
C PROGRAM FOR AND OPERATOR EXAMPLE
#include<stdio.h>
#include<conio.h>
void main()
{
int a=7, b=6, c=3;
if(a > b && a > c)
printf("Largest value is: %d",a);
else if(b > a && b > c)
printf("Largest value is: %d",b);
else
printf("Largest value is: %d",c);
getch();
}
printf("Largest value is: %d",c);
getch();
}
C PROGRAM FOR OR OPERATOR EXAMPLE
#include<stdio.h>
#include<conio.h>
void main()
{
int a=7, b=6;
if(a < b || a == c)
printf("Sum is: %d",a+b);
else
printf("Subtraction is: %d",a-b);
#include<stdio.h>
#include<conio.h>
void main()
{
int a=7, b=6;
if(a < b || a == c)
printf("Sum is: %d",a+b);
else
printf("Subtraction is: %d",a-b);
getch();
}
C PROGRAM FOR NOT OPERATOR EXAMPLE
#include<stdio.h>
#include<conio.h>
void main()
{
int n=5
if(n % 2 != 0)
printf("Odd number");
else
printf("Even number");
#include<stdio.h>
#include<conio.h>
void main()
{
int n=5
if(n % 2 != 0)
printf("Odd number");
else
printf("Even number");
getch();
}
HOME
0 Comments