• C Data Types
  • C Operators
  • C Input and Output
  • C Control Flow
  • C Functions
  • C Preprocessors
  • C File Handling
  • C Cheatsheet
  • C Interview Questions

Assignment Operators in C

assignment code for c

Assignment operators are used for assigning value to a variable. The left side operand of the assignment operator is a variable and right side operand of the assignment operator is a value. The value on the right side must be of the same data-type of the variable on the left side otherwise the compiler will raise an error.

Different types of assignment operators are shown below:

1. “=”: This is the simplest assignment operator. This operator is used to assign the value on the right to the variable on the left. Example:

2. “+=” : This operator is combination of ‘+’ and ‘=’ operators. This operator first adds the current value of the variable on left to the value on the right and then assigns the result to the variable on the left. Example:

If initially value stored in a is 5. Then (a += 6) = 11.

3. “-=” This operator is combination of ‘-‘ and ‘=’ operators. This operator first subtracts the value on the right from the current value of the variable on left and then assigns the result to the variable on the left. Example:

If initially value stored in a is 8. Then (a -= 6) = 2.

4. “*=” This operator is combination of ‘*’ and ‘=’ operators. This operator first multiplies the current value of the variable on left to the value on the right and then assigns the result to the variable on the left. Example:

If initially value stored in a is 5. Then (a *= 6) = 30.

5. “/=” This operator is combination of ‘/’ and ‘=’ operators. This operator first divides the current value of the variable on left by the value on the right and then assigns the result to the variable on the left. Example:

If initially value stored in a is 6. Then (a /= 2) = 3.

Below example illustrates the various Assignment Operators:

Similar Reads

  • C-Operators
  • cpp-operator

Improve your Coding Skills with Practice

 alt=

What kind of Experience do you want to share?

01 Career Opportunities

02 beginner, 03 intermediate, 04 advanced, 05 training programs, c programming assignment operators, free c programming certification course: essential c language skills for beginners, what is an assignment operator in c, types of assignment operators in c, 1. simple assignment operator (=), example of simple assignment operator, 2. compound assignment operators, example of augmented arithmetic and assignment operators, example of augmented bitwise and assignment operators, practice problems on assignment operators in c, 1. what will the value of "x" be after the execution of the following code, 2. after executing the following code, what is the value of the number variable, benefits of using assignment operators, best practices and tips for using the assignment operator, about author, live batches schedule view all.

IMAGES

  1. Assignment Operators in C

    assignment code for c

  2. [100% Working Code]

    assignment code for c

  3. Assignment Operators in C Example

    assignment code for c

  4. [100% Working Code]

    assignment code for c

  5. Assignment Operators in C Programming

    assignment code for c

  6. C# Assignment Operator

    assignment code for c

VIDEO

  1. Assignment Operator in C Programming

  2. Problem Solving Through Programming In C Week 11

  3. AIOU Solved Assignments Autumn 2024

  4. AIOU Code 247 Solved Assignment No 1 Autumn 2024

  5. day -8 c series #coding #featured #shorts #code

  6. C++ Tutorial for beginners || Operators || Assignment Operator