Search
 
SCRIPT & CODE EXAMPLE
 

CPP

how to use decrement operator in c++

#include <iostream>
using namespace std;

int main()
{
  int x = 5, y = 5;
  
  cout << x-- << " " << --y ;
  // Outputs 5 4
  
  return 0;
}
Comment

increment c++

int main(){
  int i = 0;
  cout << i << endl; //Outputs 0
  i++; //Now i is 0 + 1
  cout << i << endl; // Outputs 1
  return 0;
}
Comment

C++ Increment and Decrement

	int b, a, e, d, c, f;
    int num = 57;
    cout << "The number is " << num << endl;

    b = ++num;
    a = ++num;
    e = a + 1;
    cout << "After post increment by 1, the number is " << b << endl;
    cout << "After pre increment by 1, the number is " << a << endl;
    cout << "After increasing by 1, the number is " << e << endl;

    d = --e;
    c = --e;
    f = c - 1;
    cout << "After post decrement by 1, the number is " << d << endl;
    cout << "After pre decrement by 1, the number is " << c << endl;
    cout << "After decreasing by 1, the number is " << f << endl;
Comment

decrement c++

int x = 5;
x--;
cout << x << endl;
//outputs 4
Comment

PREVIOUS NEXT
Code Example
Cpp :: c++ lettura file 
Cpp :: cpp vector 
Cpp :: travelling salesman problem c++ 
Cpp :: print stack without pop c++ 
Cpp :: linked list in c++ 
Cpp :: cpp define function 
Cpp :: c++ exceptions 
Cpp :: c++ move semantics for `this` 
Cpp :: find substring in string c++ 
Cpp :: insert element in array c++ 
Cpp :: rotate an array of n elements to the right by k steps 
Cpp :: count sort algorithm 
Cpp :: polymorphism in c++ 
Cpp :: string reverse iterator c++ 
Cpp :: opencv c++ feature detection 
Cpp :: substring in c++ 
Cpp :: print hola mundo 
Cpp :: get std string from file 
Cpp :: constrain function in arduino 
Cpp :: printing in column c++ 
Cpp :: converting char to integer c++ 
Cpp :: Euler constant 
Cpp :: C++ if...else...else if statement 
Cpp :: files in c++ 
Cpp :: Start mongodb community server 
Cpp :: c++ check if number is even or odd 
Cpp :: if not c++ 
Cpp :: floor and ceil in cpp 
Cpp :: min heap 
Cpp :: sstream c++ 
ADD CONTENT
Topic
Content
Source link
Name
5+4 =