By combining a math operator with the equal sign, an assignment operator allows a variable's value to be modified without crafting a more complex expression. Use an assignment operator to self-modify a variable's value, such as adding, subtracting, multiplying, dividing, or performing other operations on the same variable.
- The format for self-modifying a variable … is shown in this code. … Variable a is declared and initialized to the value 25 … at line five. … Line eight, adds five to the value of variable a, … line 10 subtracts five. … Line 12 multiplies whatever's in a by five … and line 14 divides a … by five. … Build and run. … These expressions work in C … because the right side of the assignment operator … is evaluated first. … The answer is calculated on the right … then the answer slides over through the equal sign … and into the variable on the left, but there is a shortcut. … Here's the same code, but using assignment operators. … Line eight increases the value of variable a by five, … line 10 decreases, … 12 multiplies the value of variable a by five … and line 14 divides the value of variable a by five. … Build and run, and the output is the same. … To modify the value of a variable by itself, … put the expression on the right side of the equal sign. … The operator goes on the left. … Here are the C language assignment operators, …
- Writing your first C program
- Working the C development cycle
- Adding comments to code for clarity
- C language data types
- Declaring variables
- Making new data types
- Typecasting variables
- Using math, assignment, and logical operators
- Creating for and while loops
- Nesting loops
- Creating functions
- Returning values from functions
- Passing arguments to functions
- Creating recursive functions
Skill Level Intermediate
C: Data Structures, Pointers, and File Systemswith Dan Gookin2h 57m Intermediate
1. The Fundamentals of C
2. Variables and Values
3. Operators and Math
4. Decisions and Loops
Next steps1m 38s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.