Operators in C Programming Notes | Basic Computer Engineering | RGPV BTech First Year

Operators in C Programming Notes | Basic Computer Engineering | RGPV BTech First Year


Operators in C Programming

Operators C Programming Language рдХреЗ рд╕рдмрд╕реЗ рдорд╣рддреНрд╡рдкреВрд░реНрдг Components рдореЗрдВ рд╕реЗ рдПрдХ рд╣реИрдВред Operators рдРрд╕реЗ рд╡рд┐рд╢реЗрд╖ Symbols рд╣реЛрддреЗ рд╣реИрдВ рдЬрд┐рдирдХрд╛ рдЙрдкрдпреЛрдЧ Variables рддрдерд╛ Constants рдкрд░ рд╡рд┐рднрд┐рдиреНрди рдкреНрд░рдХрд╛рд░ рдХреЗ Operations рдХрд░рдиреЗ рдХреЗ рд▓рд┐рдП рдХрд┐рдпрд╛ рдЬрд╛рддрд╛ рд╣реИред рдЗрдирдХреЗ рдмрд┐рдирд╛ рдХрд┐рд╕реА рднреА Program рдореЗрдВ Calculation, Comparison, Decision Making рддрдерд╛ Logical Processing рд╕рдВрднрд╡ рдирд╣реАрдВ рд╣реИред C Language рдореЗрдВ рд╡рд┐рднрд┐рдиреНрди рдкреНрд░рдХрд╛рд░ рдХреЗ Operators рдЙрдкрд▓рдмреНрдз рд╣реИрдВ рдЬреЛ Program рдХреЛ рдЕрдзрд┐рдХ Efficient рддрдерд╛ Powerful рдмрдирд╛рддреЗ рд╣реИрдВред

Software Development, Embedded Systems, Operating Systems, Artificial Intelligence, Data Processing рддрдерд╛ Scientific Computing рдЬреИрд╕реЗ рд▓рдЧрднрдЧ рд╕рднреА рдХреНрд╖реЗрддреНрд░реЛрдВ рдореЗрдВ Operators рдХрд╛ рд╡реНрдпрд╛рдкрдХ рдЙрдкрдпреЛрдЧ рдХрд┐рдпрд╛ рдЬрд╛рддрд╛ рд╣реИред рдкреНрд░рддреНрдпреЗрдХ Programmer рдХреЗ рд▓рд┐рдП Operators рдХреА рдЕрдЪреНрдЫреА рд╕рдордЭ рдЖрд╡рд╢реНрдпрдХ рд╣реЛрддреА рд╣реИ рдХреНрдпреЛрдВрдХрд┐ Program рдХреА рдЕрдзрд┐рдХрд╛рдВрд╢ Logic рдЗрдиреНрд╣реАрдВ рдкрд░ рдЖрдзрд╛рд░рд┐рдд рд╣реЛрддреА рд╣реИред


Introduction to Operators

Operator рдПрдХ Special Symbol рд╣реЛрддрд╛ рд╣реИ рдЬреЛ Operand рдкрд░ рдХреЛрдИ рд╡рд┐рд╢реЗрд╖ Operation рдХрд░рддрд╛ рд╣реИред рдЙрджрд╛рд╣рд░рдг рдХреЗ рд▓рд┐рдП Addition (+), Subtraction (-), Multiplication (*) рддрдерд╛ Division (/) Arithmetic Operators рд╣реИрдВ рдЬреЛ Mathematical Calculations рдХреЗ рд▓рд┐рдП рдЙрдкрдпреЛрдЧ рдХрд┐рдП рдЬрд╛рддреЗ рд╣реИрдВред

Compiler Operator рддрдерд╛ Operand рдХреЛ рдкрдврд╝рдХрд░ рдЖрд╡рд╢реНрдпрдХ Operation рдХрд░рддрд╛ рд╣реИ рддрдерд╛ Result рдЙрддреНрдкрдиреНрди рдХрд░рддрд╛ рд╣реИред


Definition of Operator

Operator рд╡рд╣ Symbol рд╣реЛрддрд╛ рд╣реИ рдЬреЛ рдПрдХ рдЕрдерд╡рд╛ рдЕрдзрд┐рдХ Operands рдкрд░ Operation рдХрд░рдХреЗ Result рдкреНрд░рджрд╛рди рдХрд░рддрд╛ рд╣реИред

Operator = Symbol that Performs Operation on Operands

Need of Operators

  • Mathematical Calculations рдХреЗ рд▓рд┐рдПред
  • Decision Making рдХреЗ рд▓рд┐рдПред
  • Logical Comparison рдХреЗ рд▓рд┐рдПред
  • Assignment Operations рдХреЗ рд▓рд┐рдПред
  • Memory Manipulation рдХреЗ рд▓рд┐рдПред
  • Bit Level Processing рдХреЗ рд▓рд┐рдПред

Characteristics of Operators

  • Operate on Operands.
  • Produce Result.
  • Follow Precedence Rules.
  • Support Different Data Types.
  • Improve Programming Efficiency.
  • Essential for Program Logic.

Advantages of Operators

  • Simple Program Writing.
  • Fast Execution.
  • Easy Calculations.
  • Supports Decision Making.
  • Improves Code Readability.
  • Reduces Program Length.

Limitations of Operators

  • Incorrect Precedence Causes Errors.
  • Complex Expressions Reduce Readability.
  • Requires Proper Data Types.
  • Wrong Operator Produces Incorrect Results.

Types of Operators

C Programming рдореЗрдВ рдирд┐рдореНрди рдкреНрд░рдореБрдЦ рдкреНрд░рдХрд╛рд░ рдХреЗ Operators рдЙрдкрд▓рдмреНрдз рд╣реИрдВред

  1. Arithmetic Operators
  2. Relational Operators
  3. Logical Operators
  4. Assignment Operators
  5. Increment and Decrement Operators
  6. Bitwise Operators
  7. Conditional (Ternary) Operator
  8. sizeof Operator

Arithmetic Operators

Arithmetic Operators рдХрд╛ рдЙрдкрдпреЛрдЧ Mathematical Calculations рдХрд░рдиреЗ рдХреЗ рд▓рд┐рдП рдХрд┐рдпрд╛ рдЬрд╛рддрд╛ рд╣реИред

Operator Operation
+ Addition
- Subtraction
* Multiplication
/ Division
% Modulus
int a=20,b=10; printf("%d",a+b);

Relational Operators

Relational Operators рджреЛ Values рдХреА рддреБрд▓рдирд╛ (Comparison) рдХрд░рдиреЗ рдХреЗ рд▓рд┐рдП рдЙрдкрдпреЛрдЧ рдХрд┐рдП рдЬрд╛рддреЗ рд╣реИрдВред рдЗрдирдХрд╛ рдкрд░рд┐рдгрд╛рдо True (1) рдЕрдерд╡рд╛ False (0) рд╣реЛрддрд╛ рд╣реИред

Operator Meaning
== Equal To
!= Not Equal To
> Greater Than
< Less Than
>= Greater Than Equal
<= Less Than Equal

Logical Operators

Logical Operators рдХрд╛ рдЙрдкрдпреЛрдЧ Multiple Conditions рдХреЛ Combine рдХрд░рдиреЗ рдХреЗ рд▓рд┐рдП рдХрд┐рдпрд╛ рдЬрд╛рддрд╛ рд╣реИред рдпреЗ рдореБрдЦреНрдп рд░реВрдк рд╕реЗ Decision Making Statements рдореЗрдВ рдЙрдкрдпреЛрдЧ рд╣реЛрддреЗ рд╣реИрдВред

Operator Meaning
&& Logical AND
|| Logical OR
! Logical NOT

Assignment Operators

Assignment Operators рдХрд╛ рдЙрдкрдпреЛрдЧ Variables рдореЗрдВ Values Store рдХрд░рдиреЗ рдХреЗ рд▓рд┐рдП рдХрд┐рдпрд╛ рдЬрд╛рддрд╛ рд╣реИред Compound Assignment Operators Program рдХреЛ рдЫреЛрдЯрд╛ рддрдерд╛ рдЕрдзрд┐рдХ Efficient рдмрдирд╛рддреЗ рд╣реИрдВред

Operator Meaning
= Assign Value
+= Add and Assign
-= Subtract and Assign
*= Multiply and Assign
/= Divide and Assign

Increment and Decrement Operators

Increment (++) рддрдерд╛ Decrement (--) Operators рдХрд╛ рдЙрдкрдпреЛрдЧ Variable рдХреЗ рдорд╛рди рдХреЛ 1 рд╕реЗ рдмрдврд╝рд╛рдиреЗ рдЕрдерд╡рд╛ 1 рд╕реЗ рдШрдЯрд╛рдиреЗ рдХреЗ рд▓рд┐рдП рдХрд┐рдпрд╛ рдЬрд╛рддрд╛ рд╣реИред рдпреЗ Operators рджреЛ рдкреНрд░рдХрд╛рд░ рдХреЗ рд╣реЛрддреЗ рд╣реИрдВ тАФ Pre Increment/Decrement рддрдерд╛ Post Increment/Decrementред

Operator Purpose
++a Pre Increment
a++ Post Increment
--a Pre Decrement
a-- Post Decrement
int a = 5; a++; ++a;

Bitwise Operators

Bitwise Operators Integer Data рдХреА рдкреНрд░рддреНрдпреЗрдХ Bit рдкрд░ Operation рдХрд░рддреЗ рд╣реИрдВред рдЗрдирдХрд╛ рдЙрдкрдпреЛрдЧ Embedded Systems, Device Drivers рддрдерд╛ Low Level Programming рдореЗрдВ рдЕрдзрд┐рдХ рдХрд┐рдпрд╛ рдЬрд╛рддрд╛ рд╣реИред

Operator Meaning
& Bitwise AND
| Bitwise OR
^ Bitwise XOR
~ Bitwise NOT
<< Left Shift
>> Right Shift

Conditional (Ternary) Operator

Conditional Operator (?:) рдПрдХ Short Decision Making Operator рд╣реИ рдЬреЛ if-else Statement рдХрд╛ рд╕рдВрдХреНрд╖рд┐рдкреНрдд рд░реВрдк рдорд╛рдирд╛ рдЬрд╛рддрд╛ рд╣реИред рдпрд╣ рдХрд┐рд╕реА Condition рдХреЗ рдЖрдзрд╛рд░ рдкрд░ рджреЛ Expressions рдореЗрдВ рд╕реЗ рдПрдХ рдХреЛ Execute рдХрд░рддрд╛ рд╣реИред

int max = (a>b) ? a : b;

sizeof Operator

sizeof Operator рдХрд╛ рдЙрдкрдпреЛрдЧ рдХрд┐рд╕реА Variable рдЕрдерд╡рд╛ Data Type рджреНрд╡рд╛рд░рд╛ Memory рдореЗрдВ рд▓реА рдЧрдИ Size (Bytes) рдЬреНрдЮрд╛рдд рдХрд░рдиреЗ рдХреЗ рд▓рд┐рдП рдХрд┐рдпрд╛ рдЬрд╛рддрд╛ рд╣реИред

printf("%d", sizeof(int)); printf("%d", sizeof(float));

Operator Precedence and Associativity

рдЬрдм рдХрд┐рд╕реА Expression рдореЗрдВ рдЕрдиреЗрдХ Operators рд╣реЛрддреЗ рд╣реИрдВ, рддрдм рдпрд╣ рдирд┐рд░реНрдзрд╛рд░рд┐рдд рдХрд░рдирд╛ рдЖрд╡рд╢реНрдпрдХ рд╣реЛрддрд╛ рд╣реИ рдХрд┐ рдХреМрди-рд╕рд╛ Operator рдкрд╣рд▓реЗ Execute рд╣реЛрдЧрд╛ред рдЗрд╕рдХреЗ рд▓рд┐рдП Operator Precedence рддрдерд╛ Associativity рдХрд╛ рдЙрдкрдпреЛрдЧ рдХрд┐рдпрд╛ рдЬрд╛рддрд╛ рд╣реИред

Operator Associativity
() Left to Right
++, -- Right to Left
*, /, % Left to Right
+, - Left to Right
= Right to Left

Difference between Arithmetic and Logical Operators

Arithmetic Operators Logical Operators
Perform Mathematical Operations. Perform Logical Comparison.
Return Numeric Result. Return True (1) or False (0).
Examples: +, -, *, /. Examples: &&, ||, !.

Applications of Operators

  • Mathematical Calculations.
  • Decision Making.
  • Loop Control.
  • Data Validation.
  • Embedded Systems.
  • Operating System Development.
  • Game Development.
  • Artificial Intelligence.
  • Database Applications.
  • Scientific Computing.

Common Errors

  • Using "=" instead of "==".
  • Ignoring Operator Precedence.
  • Division by Zero.
  • Incorrect Increment Usage.
  • Wrong Bitwise Operations.
  • Missing Parentheses in Expressions.

Best Practices

  • Use Parentheses to Improve Readability.
  • Understand Operator Precedence.
  • Use Meaningful Expressions.
  • Avoid Complex Nested Expressions.
  • Validate Input Before Operations.
  • Test Expressions Carefully.

Industrial Importance

Operators рдкреНрд░рддреНрдпреЗрдХ Programming Language рдХреА рдореВрд▓рднреВрдд рдЗрдХрд╛рдИ рд╣реИрдВред рдЖрдзреБрдирд┐рдХ Software Development, Operating Systems, Embedded Systems, Artificial Intelligence, Robotics, IoT рддрдерд╛ High Performance Computing рдореЗрдВ Operators рдХрд╛ рд╡реНрдпрд╛рдкрдХ рдЙрдкрдпреЛрдЧ рд╣реЛрддрд╛ рд╣реИред рд╡рд┐рд╢реЗрд╖ рд░реВрдк рд╕реЗ Bitwise Operators рддрдерд╛ Conditional Operators Low-Level Programming рддрдерд╛ Performance Optimization рдореЗрдВ рдЕрддреНрдпрдВрдд рдорд╣рддреНрд╡рдкреВрд░реНрдг рднреВрдорд┐рдХрд╛ рдирд┐рднрд╛рддреЗ рд╣реИрдВред


Viva Questions

  1. What is an Operator in C?
  2. Why are Operators required?
  3. Explain Arithmetic Operators.
  4. What are Relational Operators?
  5. Explain Logical Operators.
  6. Differentiate Assignment and Arithmetic Operators.
  7. What is the Conditional Operator?
  8. Explain sizeof Operator.
  9. What is Operator Precedence?
  10. State the applications of Operators.

Exam Oriented Important Questions

  1. Define Operators with suitable examples.
  2. Explain different types of Operators in C.
  3. Discuss Arithmetic, Relational and Logical Operators.
  4. Explain Assignment, Bitwise and Conditional Operators.
  5. Describe Increment and Decrement Operators with examples.
  6. Explain Operator Precedence and Associativity.
  7. Differentiate Arithmetic and Logical Operators.
  8. Write short notes on sizeof Operator and Bitwise Operators.

Conclusion

Operators C Programming рдХреА рд╕рдмрд╕реЗ рдорд╣рддреНрд╡рдкреВрд░реНрдг рд╡рд┐рд╢реЗрд╖рддрд╛рдУрдВ рдореЗрдВ рд╕реЗ рдПрдХ рд╣реИрдВред рдЗрдирдХреЗ рдорд╛рдзреНрдпрдо рд╕реЗ Mathematical Calculations, Decision Making, Memory Manipulation рддрдерд╛ Logical Processing рдХреЛ рд╕рд░рд▓ рдПрд╡рдВ рдкреНрд░рднрд╛рд╡реА рдмрдирд╛рдпрд╛ рдЬрд╛рддрд╛ рд╣реИред Operators рдХреА рдЕрдЪреНрдЫреА рд╕рдордЭ рд╡рд┐рджреНрдпрд╛рд░реНрдерд┐рдпреЛрдВ рдХреЛ Efficient рддрдерд╛ Error-Free Programs рд╡рд┐рдХрд╕рд┐рдд рдХрд░рдиреЗ рдореЗрдВ рд╕рд╣рд╛рдпрддрд╛ рдХрд░рддреА рд╣реИред

Related Articles

Manipulators in C++ Notes | endl, setw, setprecision, setfill | Basic Computer Engineering | RGPV BTech First Year

0...

Read More тЖТ

Type Conversion in C++ Notes | Basic Computer Engineering | RGPV BTech First Year

Type Co...

Read More тЖТ

Assignment Operator in C++ Notes | Basic Computer Engineering | RGPV BTech First Year

Assignm...

Read More тЖТ

Copy Constructor in C++ Notes | Basic Computer Engineering | RGPV BTech First Year

Copy Co...

Read More тЖТ

this Pointer in C++ Notes | Basic Computer Engineering | RGPV BTech First Year

this Po...

Read More тЖТ