Showing posts with label Logical Operator. Show all posts
Showing posts with label Logical Operator. Show all posts

Thursday, 2 February 2012

Program Of Logical Operator In C++


#include<stdio.h>
#include<conio.h>
main()
{
clrscr();
printf("Enter Character=");
scanf("%c",&ch);

{
printf("\n Given Character is Vowel");
}
else
{
printf("\n Given Character is Consonants");
}
getch();
}

Saturday, 28 January 2012

Program Of Logical Operators In C


#include<stdio.h>
#include<conio.h>
main()
{
int a,b,c;
clrscr();
printf("Enter First Number=");
scanf("%d",&a);
printf("Enter Second Number=");
scanf("%d",&b);
printf("Enter Third Number=");
scanf("%d",&c);
if(a>b && a>c)
{
printf("\n A is Greater");
}

if(b>a && b>c)
{
printf("\n B is Greater");
}
if(c>a && c>b)
{
printf("\n C is Greater");
}
getch();
}
--------------------------------------------------------------

The logical operators compare Boolean expressions and return a Boolean result. The And, Or, AndAlso, OrElse, and Xor operators take two operands, and the Not operator takes a single operand.

The Not operator performs logical negation on a Boolean expression. Put simply, it yields the opposite of the expression it evaluates. If the expression evaluates to True, Not yields False; if the expression evaluates to False, Not yields True. An example is shown below:


Dim x As Boolean x = Not 23 > 12 ' x equals False. x = Not 23 > 67 ' x equals True.


The And operator performs logical conjunction on two Boolean expressions. That is, if both expressions evaluate to True, then the And operator returns True. If either or both expressions evaluate to False, then And returns False.

The Or operator performs logical disjunction on two Boolean expressions. If either expression evaluates to True, Or returns True. If neither expression evaluates to True, Or returns False.

Xor performs logical exclusion on two expressions. If either expression evaluates to True, but not both, Xor returns True. If both expressions evaluate to True or both expressions evaluate toFalse, Xor returns False.