What is the “–>” operator in C++?

Most of the coder surprise to see this operator “–>” in C++ /C. Actually, it is not any new operator if you see this operator closely then you saw that these “–>” operator is actually a combination of the operator. It is a combination of the decrement operator “–” and greater than “>”. Let we more clear let it implement in code.

For Example : We Print Natural Number

#include <iostream>

using namespace std;

int main()
{
    int number=10;
    cout<<"Print 10 Number";
    while(number --> 0)
    {
        cout<<number<<endl;
    }

    return 0;
}
Output:Print 10 Number 9 8 7 6 5 4 3 2 1 0

For More Understanding, we convert “ while(number –> 0)   to  while((number –)>0)

#include <iostream>

using namespace std;

int main()
{
    int number=10;
    cout<<"Print 10 Number ";
    while((number--)> 0)
    {
        cout<<number<<" ";
    }

    return 0;
}
Output:Print 10 Number 9 8 7 6 5 4 3 2 1 0

For More Learn about C++

Leave a Reply

%d bloggers like this: