C operators

Created By: chatGPT

C operators are symbols that tell the compiler to perform specific mathematical or logical manipulations. They can be classified into several categories, including arithmetic, relational, logical, bitwise, assignment, and more. Understanding these operators is crucial for writing efficient and effective C programs.Here is an overview of some common arithmetic operators:Addition (+), Subtraction (-), Multiplication (*), Division (/), and Modulus (%) are the primary arithmetic operators used to perform basic math operations.
Example usage of arithmetic operators:
int a = 10;
int b = 20;
int sum = a + b;
int product = a * b;
int division = b / a;
int remainder = b % a;
Relational operators allow you to compare two values. They return boolean results (true or false). The primary relational operators include:Equal to (==), Not equal to (!=), Greater than (>), Less than (<), Greater than or equal to (>=), Less than or equal to (<=).
Example for relational operators:
if (a == b) {
    // Code to execute if a is equal to b
}
if (a < b) {
    // Code to execute if a is less than b
}
Logical operators are used to perform logical operations, commonly used in conditional statements. They include:Logical AND (&&), Logical OR (||), Logical NOT (!).
Example for logical operators:
if (a < b && b > 0) {
    // Code if both conditions are true
}
if (!(a == b)) {
    // Code if a is not equal to b
}
Bitwise operators are used to perform operations on bits. They include:Bitwise AND (&), Bitwise OR (|), Bitwise XOR (^), Bitwise NOT (~), Left Shift (<<), and Right Shift (>>).
Example for bitwise operators:
int x = 5;  // 0101 in binary
int y = 3;  // 0011 in binary
int result = x & y;  // Result is 1 (0001 in binary)
Assignment operators are used to assign values to variables. The most common include:Simple assignment (=), Add and assign (+=), Subtract and assign (-=), Multiply and assign (*=), Divide and assign (/=), Modulus and assign (%=).
Example for assignment operators:
int z = 10;
z += 5;  // z is now 15
z *= 2;  // z is now 30
In summary, C operators are essential building blocks for performing operations in your programs. Mastering them will help you become proficient in C programming.
Introduction And SetupVariablesData TypesIntFloatDoubleCharVoidUnsignedSignedConstantsEnumerationsArraysStringsStructsUnionsTypedefsPointersDynamic Memory AllocationMallocCallocReallocFreeFunctionsFunction DeclarationsFunction DefinitionsFunction CallsReturn StatementInline FunctionsRecursionHeader FilesPreprocessor DirectivesControl FlowIf StatementElse StatementElse If StatementSwitch StatementCase StatementDefault CaseLoopsFor LoopWhile LoopDo While LoopBreak StatementContinue StatementGoto StatementLabelsOperatorsArithmetic OperatorsRelational OperatorsLogical OperatorsBitwise OperatorsAssignment OperatorsConditional (ternary) OperatorComma OperatorSizeof OperatorData StructuresLinked ListsStacksQueuesTreesGraphsFunction PointersCallbacksMacrosCommentsSingle Line CommentsMulti Line CommentsSyntaxSyntax ErrorsCompilation ErrorsDebuggingStandard Input OutputPrintfScanfFile HandlingFopenFcloseFreadFwriteFprintfFgetsFputsError HandlingErrnoAssertionsExit FunctionExit CodesEvent HandlingSignal HandlingInterrupts