Search
 
SCRIPT & CODE EXAMPLE
 

CPP

What is the "-->" operator in C/C++?

--> 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 ) 
Comment

c++ .* operator

The .* operator is used to dereference pointers to class members.
Comment

Operators in C / C++

// 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
Comment

c/c++ ? operator

#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
}
Comment

C++ Operators

int sum1 = 100 + 50;        // 150 (100 + 50)
int sum2 = sum1 + 250;      // 400 (150 + 250)
int sum3 = sum2 + sum2;     // 800 (400 + 400)
Comment

c++ & operator

Is used to declare a reference to other variables and such.
Comment

PREVIOUS NEXT
Code Example
Cpp :: c++ formatting 
Cpp :: . Write a C++ program to calculate area of a Triangle 
Cpp :: google test assert throw 
Cpp :: volumeof a sphere 
Cpp :: minheap cpp stl 
Cpp :: Array declaration by specifying the size in C++ 
Cpp :: c++ compare type 
Cpp :: Abstract factory C++ code 
Cpp :: balanced brackets in c++ 
Cpp :: c++ generic pointer 
Cpp :: DS1302 
Cpp :: how can I delete a substring from a string in c++? 
Cpp :: c++ sorting and keeping track of indexes 
Cpp :: round c++ 
Cpp :: c++ string concatenation 
Cpp :: cpp custom exception 
Cpp :: invert a binary tree 
Cpp :: binary to decimal 
Cpp :: file streams in c++ 
Cpp :: c++ visual studio 
Cpp :: check if cin got the wrong type 
Cpp :: why exceptions can lead to memory leaks 
Cpp :: short int range in c++ 
Cpp :: parking charge system project c++ 
Cpp :: point in polygon 
Cpp :: turbo c++ easy programs 
Cpp :: what does map.count() return in c++ 
Cpp :: c++ argument list for class template is missing 
Cpp :: Missing GL version 
Cpp :: Print value of data in c++ 
ADD CONTENT
Topic
Content
Source link
Name
4+4 =