Assignment Operator C++ -C++ ProgrammingOnline

Hello! Dear Students! Today we will discuss the chapter Assignment Operator C++ of C++ Programming Online free course.

This is One n only operator “=”, but it has a lot of functions.

So, Assignment Operators

Assignment operator are using to assign a value and variable.

In the Example below, we are using the Assignment operator “=” to assign two values 15 and 20 with the two variables of x and y.

Then, look at the Example:

#include <iostream>
using namespace std;

int main(){
    int x = 15;
    int y = 20;
    cout << x << endl << y;
    return 0;
}

So, see at Output:

15
20

So, let me explain why I write cout << x << endl << y;. because its a valid method to write this. So, you can give output two variable at same line and you can put endl in mid to line break.

Let us do another example with another assignment operator “+=” and assign value and a variable.

So, Example:

#include <iostream>
using namespace std;

int main(){
    int x = 5;
     x += 10;
    cout << x;
    return 0;
}

Then, the Output:

15

The list of Assignment Operator C++

So, peoples I am uploading the list of Assignment Operator. here and FB.

Assignment Operator C++ Programming Online
Assignment Operator C++ Programming Online

So, See The Example with output:

The Starter Template:

#include <iostream>
using namespace std;

int main(){
      // Data 
}

So, I am gone a try to explain all operators. in below this section.

x = 10;
x += 5;
so, the output: 15

x = 10;
x *= 5;
so, the output: 50

x = 11;
x &= 5;
so, the output: 1

x = 10;
x ^= 5;
so, the output: 15

x = 10;
x = x << 5;
so, the output: 320

x = 10;
x = x >> 3;
so, the output: 1

Dear Students, We upload all Chapters of C++ on this website, So, Read the Assignment Operators, Variable Char Boolean and string, Data Type Numeric, another complete chapter about Data Types, User Input, and Output and more many chapters.

So, Students give us Feedback, in comment section, about C++ Programming Online free course.

If you want deeply learn about C++ Operators, so learn more gain knowledge more!

By Usama Arshad

It's me Usama Arshad working as a Lecturer C++. I am a student of BSIT.

Leave a Reply

Your email address will not be published. Required fields are marked *