Search
 
SCRIPT & CODE EXAMPLE
 

C

increment and decrement operator

Increment Operators: The increment operator is used to increment the value of 
a variable in an expression. In the Pre-Increment, value is first incremented 
and then used inside the expression. Whereas in the Post-Increment, value is 
first used inside the expression and then incremented.

Decrement Operators: The decrement operator is used to decrement the value of 
a variable in an expression. In the Pre-Decrement, value is first decremented 
and then used inside the expression. Whereas in the Post-Decrement, value is 
first used inside the expression and then decremented.
Comment

increment operator

i++ i-- ++i --i
Comment

Incrementing / Decrementing Operators

Example    Name              Effect
---------------------------------------------------------------------
++$a       Pre-increment     Increments $a by one, then returns $a.
$a++       Post-increment    Returns $a, then increments $a by one.
--$a       Pre-decrement     Decrements $a by one, then returns $a.
$a--       Post-decrement    Returns $a, then decrements $a by one.
Comment

Increment and Decrement Operators

// Working of increment and decrement operators

#include <iostream>
using namespace std;

int main() {
    int a = 10, b = 100, result_a, result_b;

    // incrementing a by 1 and storing the result in result_a
    result_a = ++a;
    cout << "result_a = " << result_a << endl;


    // decrementing b by 1 and storing the result in result_b   
    result_b = --b;
    cout << "result_b = " << result_b << endl;

    return 0;
}
Comment

PREVIOUS NEXT
Code Example
C :: c strcmp 
C :: why do you jerk while falling aslee 
C :: how to free memory in c 
C :: how to input till end of line in c 
C :: c structure with pointer 
C :: command line arguments c 
C :: check if string contains a character in c 
C :: rust set toolchain 
C :: snprintf c 
C :: c command line arguments parser 
C :: fifo in c 
C :: c function definition 
C :: sphinx-doc 
C :: C How to define a union? 
C :: c code recursive function to print numbers between two numbers 
C :: arduino internal pull up resistor 
C :: C/c drop mime 
C :: How can you invoke the constructor from the parent class? *ruby 
C :: findtotalcurtain 
C :: phpunit assert continue 
C :: binary operations on structs C 
C :: #pragma pack(1) in c 
C :: how to alias an awk command 
C :: Implement N-Queen Problem 
C :: C linked sorted lists 
C :: changing data type in one line c program 
C :: cannot reach esp8266 via udp while he is running with a static ip 
C :: C static libraries (creating archive from object files) 
C :: online embedded c compiler 
C :: download file by command line windows 
ADD CONTENT
Topic
Content
Source link
Name
4+8 =