TestingDocs.com
Software Testing website
  • Automation
    • Selenium
    • JBehave Framework
  • Tutorials
    • MySQL Tutorials
    • Testlink
    • Maven
    • Git
  • IDEs
    • IntelliJ IDEA
    • Eclipse
  • Flowcharts
    • Flowgorithm
    • Raptor
  • About

Octave

Octave Increment & Decrement operators

Overview

In this tutorial, we will learn about Octave Increment & Decrement Operator. The increment and decrement in Octave are unary operators. They take and operate on a single operand.

Increment Operator

The increment operator is used to increment the variable value by 1. We can apply the operator before or after the operand.

  • Pre-increment
  • Post-increment

Pre-increment the value of the variable is increased and then used in the expression.

For example;

++x  is equivalent to

x = x + 1

Post-increment the present value of the variable is used in the expression and then the value of the variable is increased.

x++

For example, if the variable x =7 then the expression that has x++ uses the value 7 and then increments the value of x variable to 8.

Example

>> i = 10;
>> ++i % Pre-increment operator
ans = 11
>> i
i = 11
>> i++ % Post-increment operator
ans = 11
>> i
i = 12

Octave Increment Operator

Decrement Operator

The decrement operator is used to decrement the variable value by 1. We can apply the operator before or after the operand.

  • Pre-decrement
  • Post-decrement

For example;

–x  is equivalent to

x = x – 1

Example

>> i = 10;
>> –i % Pre-decrement
ans = 9
>> i
i = 9
>> i– % Post-decrement
ans = 9
>> i
i = 8

 

Octave Decrement Operator

—

Octave Tutorials

Octave Tutorial on this website can be found at:
https://www.testingdocs.com/octave-tutorial/

More information on Octave can be found on the official website:
https://www.gnu.org/software/octave/index

Related Posts

Octave Package List

Octave /

Install Octave Packages on Linux

Octave /

Octave User defined Function Example

octave command line linux

Octave /

Octave Command line on Ubuntu

Hello World in Octave

Octave /

Hello World in Octave

Octave /

Octave plot example of function y=x^2

‹ Octave Comparison Operators› Declare Variables in Octave

Recent Posts

  • MS Access Data Types
  • Install RAPTOR Avalonia on CentOS
  • Download RAPTOR Avalonia Edition on Windows
  • npm doctor command
  • Build & Run CLion Project
  • Create New CLion C Project on Windows
  • Configure CLion Toolchains on Windows
  • Launch CLion IDE on Windows
  • Activate CLion IDE
  • CLion IDE for C/C++ Development

Back to Top

Links

  • Contact
  • Privacy Policy
  • Cookie Policy

www.TestingDocs.com

Go to mobile version