--> is not an operator. It is in fact two separate operators, -- and >.
The conditional's code decrements x, while returning x's original (not decremented) value, and then compares the original value with 0 using the > operator.
To better understand, the statement could be written as follows:
while( (x--) > 0 )
The .* operator is used to dereference pointers to class members.
// Operators in C++
#include<iostream>
using namespace std;
int main(){
int a=10, b=5;
// Arithmetic operators
cout<<"Following are the Arithmetic operators in C++"<<endl;
cout<<"The value of a + b is "<<a+b<<endl;
cout<<"The value of a - b is "<<a-b<<endl;
cout<<"The value of a * b is "<<a*b<<endl;
cout<<"The value of a / b is "<<a/b<<endl;
cout<<"The value of a % b is "<<a%b<<endl;
cout<<"The value of a++ is "<<a++<<endl; // First print (a) and then increment it by 1
cout<<"The value of a-- is "<<a--<<endl; // First print (a+1) and then decrease it by 1
cout<<"The value of ++a is "<<++a<<endl; // Increment (a) by (a+1) and then print
cout<<"The value of --a is "<<--a<<endl; // Decrement (a+1) by (a) and then print
cout<<endl;
// Assignment Operators --> used to assign values to variables
// int a =3, b=9;
// char d='d';
// Comparison operators
// Output of all these comparison operators will be (1) if it is true and (0) if it is false
cout<<"Following are the comparison operators in C++"<<endl;
cout<<"The value of a == b is "<<(a==b)<<endl;
cout<<"The value of a != b is "<<(a!=b)<<endl;
cout<<"The value of a >= b is "<<(a>=b)<<endl;
cout<<"The value of a <= b is "<<(a<=b)<<endl;
cout<<"The value of a > b is "<<(a>b)<<endl;
cout<<"The value of a < b is "<<(a<b)<<endl;
cout<<endl;
// Logical operators
cout<<"Following are the logical operators in C++"<<endl;
cout<<"The value of this logical and operator ((a==b) && (a<b)) is:"<<((a==b) && (a<b))<<endl;
cout<<"The value of this logical or operator ((a==b) || (a<b)) is:"<<((a==b) || (a<b))<<endl;
cout<<"The value of this logical not operator (!(a==b)) is:"<<(!(a==b))<<endl;
return 0;
}
// This code is contributed by Suruchi Kumari
#include <iostream>
int main()
{
int value = (1 > 0 ? 12 : 41);
/*
if 1 > 0 then value is 12, else 41
*/
int val2 = (1 > 0 ? (2 > 4 ? 42 : 45) : 41); // nested
}
int sum1 = 100 + 50; // 150 (100 + 50)
int sum2 = sum1 + 250; // 400 (150 + 250)
int sum3 = sum2 + sum2; // 800 (400 + 400)
Code Example |
---|
Cpp :: c++ back() |
Cpp :: cpp mark getter as const |
Cpp :: new float array c++ |
Cpp :: integer range in c++ |
Cpp :: remove element from vector |
Cpp :: 2d vector in cpp |
Cpp :: c++ check substring |
Cpp :: c elif |
Cpp :: Search Insert Position leetcode solution in cpp |
Cpp :: c++ char array size |
Cpp :: Inner Section Sticky Scroll in elementor |
Cpp :: c plus plus |
Cpp :: mac emoji shortcut |
Cpp :: define in cpp |
Cpp :: how to initialize 2d array with values c++ |
Cpp :: SUMOFPROD2 solution |
Cpp :: 31. Next Permutation leetcode solution in c++ |
Cpp :: vector in c++ |
Cpp :: stl function to reverse an array |
Cpp :: bfs to detect cycle in undirected graph |
Cpp :: opencv c++ feature detection |
Cpp :: qt make widget ignore mouse events |
Cpp :: set of vectors c++ |
Cpp :: C++ linked list iterator |
Cpp :: c++ unittest in ros |
Cpp :: C++ cout iostream |
Cpp :: variadic template in c++ |
Cpp :: C++ rename function |
Cpp :: How to pass a multidimensional array to a function in C and C++ |
Cpp :: ternary operator in c++ |