Operators
Operators
"Operators
be
are predefined in C, just like they are in most other languages, and most operators tend to
combined withthe infix style
"A logical operator (sometimes called a "Booleanoperator") is an operator that returns a Boolean
result that's based on the Boolean result of one or two other expressions
"An arithmetic operator is a mathematical function that takes two operands and performs a calculation
on them
"Other operators include assignment, relational (<, >, !=), bitwise (<<, >>,~)
C FOR BEGINNERS
Overview {lean DOodemy
Overview
"Lets discuss, arithmetic, logical., assignment and relational operators
"An arithmetic operator is amathematical function that takes two operands and performs a calculation
on them
"A logical operator (sometimes called a "Boolean operator") is an operator that returns a Boolean
result that's based on the Boolean result of one or twoother expressions
CFORBEGINNERS
BasicOperators lean Doodem
Arithmetic Operators in C
Operator Description Example
CFOR BEGINNERS
Basic Operators Leanogomme
COodemy
Logical Operators
Operator Description Example
&& Called Logical AND operator. If both the operands are (A&& B) is false.
non-zero, then the condition becomes true.
CFOR BEGINNE RS
Basic Operators {}lean Coodemy
#include <stdio.h>
int main ()
int a = 33;
int b = 15;
int result 0;
6 */
7
8 #include <stdio. h>
9
10 int main ()
11 {
12 Bool a true;
13 Bool b = true;
14 Bool result;
15
16 result= a && b;
17 I
18 printf ("%d", result) ;
19
20 return 0;
21
1
Process returned e (
Press any key to cont
Assignment Operators
Operator Description Example
CFOR BEGINNERS
Basic Operators {}leon Coodemy
Assignment Operators (cont'd)
Operator Description Example
CFORBEGINNERS
Basic Operators
leanogomm
Coodemy
Relational Operators
Operator Description Example
Checks if the values of two operands are equal or not. If yes, (A == B) is not true.
then the condition becomes true.
Checks if the values of two operands are equal or not. If the (A != B) is true.
values are not equal, then the condition becomes true.
V
Checks if the value of left operand is greater than the value of (A> B)is not true.
right operand. If yes, then the condition becomes true.
Checks if the value of left operand is less than the value of (A<B) is true.
right operand. If yes, then the condition becomes true.
Checks if the value of left operand is greater than or equal to (A >= B) is not true.
the value of right operand. If yes, then the condition
becomes true.
<= Checks if the value of left operand is less than or equal to the (A <= B) is true.
value of right operand. If yes, then the condition becomes
true.
CFOR BEGINNERS
Basic Operators {lean Codemy