Uploaded by himaja nareshit

Operators and Expressions in C Language

advertisement
C LANGUAGE
ONLINE TRAINING
HTTPS://NARESHIT.COM/COURSES/C-LANGUAGE-ONLINE-TRAINING
OPERATORS AND
EXPRESSIONS IN C
LANGUAGE
https://nareshit.com/courses/c-language-online-training
INTRODUCTION
THE C PROGRAMMING LANGUAGE, YOU NEED TO GET A GRIP ON
OPERATORS AND EXPRESSIONS. C USES SYMBOLS CALLED
OPERATORS TO PERFORM OPERATIONS ON VARIABLES AND
CONSTANTS. THESE OPERATORS COME IN HANDY WHEN YOU WANT
TO MANIPULATE DATA AND CREATE EXPRESSIONS. AN EXPRESSION IS
A MIX OF OPERATORS, CONSTANTS, AND VARIABLES THAT BOILS
DOWN TO A SINGLE VALUE.
https://nareshit.com/courses/c-language-online-training
KEY OPERATORS IN C
LANGUAGE
01
02
03
04
05
ARITHMETIC OPERATORS
RELATIONAL OPERATORS
LOGICAL OPERATORS
BITWISE OPERATORS
ASSIGNMENT OPERATORS
06
OTHER OPERATORS
07
OPERATOR PRECEDENCE AND
ASSOCIATIVITY IN C
https://nareshit.com/courses/c-language-online-training
ARITHMETIC OPERATORS:
THE C LANGUAGE USES ARITHMETIC OPERATORS TO DO BASIC MATH.
THESE INCLUDE ADDING (+) TAKING AWAY (-), TIMES (*), DIVIDE (/), AND
FINDING REMAINDERS (%).
RELATIONAL OPERATORS:
WHEN YOU WANT TO COMPARE TWO THINGS IN C, YOU USE RELATIONAL
OPERATORS. THEY GIVE YOU A YES OR NO ANSWER. ARE THESE TWO
IDENTICAL?" (==), "IS THIS DIFFERENT FROM THAT?" (!=), "IS THIS
BIGGER THAN THAT?" (>), AND "IS THIS SMALLER THAN THAT?" (<).
https://nareshit.com/courses/c-language-online-training
LOGICAL OPERATORS:
LOGICAL OPERATORS IN C HELP YOU LINK DIFFERENT CONDITIONS. THEY
FIGURE OUT HOW THESE CONDITIONS FIT TOGETHER. YOU CAN USE "AND"
(&&) TO CHECK IF TWO THINGS ARE TRUE, "OR" (||) TO SEE IF AT LEAST
ONE THING IS TRUE, AND "NOT" (!) TO FLIP A CONDITION.
BITWISE OPERATORS:
BITWISE OPERATORS WORK ON THE BITS OF WHOLE NUMBER OPERANDS.
THE OPERATIONS THAT FALL UNDER THIS CATEGORY ARE BITWISE AND
(&), BITWISE OR (|), BITWISE XOR (^), BITWISE NOT (~), LEFT SHIFT (<<),
AND RIGHT SHIFT (>>).
https://nareshit.com/courses/c-language-online-training
ASSIGNMENT OPERATORS:
ASSIGNMENT OPERATORS GIVE VALUES TO VARIABLES. THE BASIC
ASSIGNMENT OPERATOR IS (=). COMPOUND ASSIGNMENT OPERATORS
LIKE (+=, -=, *= /=) DO THE OPERATION AND GIVE THE RESULT IN ONE
STEP.
https://nareshit.com/courses/c-language-online-training
OTHER OPERATORS:
BESIDES THESE, C HAS SOME OTHER OPERATORS FOR SPECIFIC JOBS:
SIZEOF OPERATOR: FIGURES OUT THE SIZE OF ITS OPERAND.
COMMA OPERATOR ( , ): THIS CHECKS THE FIRST PART, THROWS IT
AWAY, AND GIVES BACK THE RESULT OF THE SECOND PART.
CONDITIONAL OPERATOR ( ? : ): THIS IS A THREE-PART TOOL TO MAKE
DECISIONS IN CODE.
DOT (.) AND ARROW (->) OPERATORS: THESE HELP YOU GET TO PARTS
OF CLASSES, STRUCTURES, AND UNIONS.
https://nareshit.com/courses/c-language-online-training
CAST OPERATOR: THIS CHANGES ONE TYPE OF DATA TO ANOTHER
USING (TYPE) EXPRESSION.
ADDRESSOF (&) AND DEREFERENCE (*) OPERATORS: THESE WORK
WITH POINTERS TO FIND WHERE A VARIABLE LIVES AND TO SEE WHAT'S
INSIDE A POINTER, IN THAT ORDER.
https://nareshit.com/courses/c-language-online-training
UNARY, BINARY AND TERNARY OPERATORS IN C: C GROUPS
OPERATORS INTO THREE CATEGORIES BASED ON HOW MANY OPERANDS
THEY USE:
UNARY OPERATORS: THESE WORK ON ONE OPERAND.
BINARY OPERATORS: THESE WORK ON TWO OPERANDS.
TERNARY OPERATOR: C HAS ONE TERNARY OPERATOR, WHICH IS THE
CONDITIONAL OPERATOR ( ?).
https://nareshit.com/courses/c-language-online-training
OPERATOR PRECEDENCE AND ASSOCIATIVITY IN C:
WHEN C EXPRESSIONS HAVE MULTIPLE OPERATORS, EACH OPERATOR
HAS ITS OWN PRECEDENCE AND ASSOCIATIVITY:
PRECEDENCE: DECIDES THE SEQUENCE OF EVALUATION IN EXPRESSIONS.
THE SYSTEM EVALUATES OPERATORS WITH HIGHER PRECEDENCE FIRST.
ASSOCIATIVITY: POINTS OUT THE DIRECTION FOR EVALUATING
OPERATORS WITH THE SAME PRECEDENCE LEVEL (LEFT TO RIGHT OR
RIGHT TO LEFT).
TO WRITE BUG-FREE AND SOUND CODE IN C, YOU NEED TO UNDERSTAND
OPERATOR PRECEDENCE AND ASSOCIATIVITY.
https://nareshit.com/courses/c-language-online-training
CONCLUSION:
OPERATORS AND EXPRESSIONS ARE AT THE HEART OF C PROGRAMMING.
THEY LET DEVELOPERS HANDLE DATA WELL AND WRITE SHORT CODE. IF
YOU WANT TO GET GOOD AT C PROGRAMMING, YOU MUST MASTER THESE
IDEAS.
https://nareshit.com/courses/c-language-online-training
www.naresit.com
8179191999
https://nareshit.com/courses/c-language-online-training
10
Download