+ 14

When do you use <<

I've seen the following: cout << x;

1st Dec 2017, 4:40 PM
M Abd
M Abd - avatar
3 odpowiedzi
+ 13
There are two bit shift operators in C++: the left shift operator << and the right shift operator >>. These operators cause the bits in the left operand to be shifted left or right by the number of positions specified by the right operand. example:- int a = 5; // binary: 101 int b = a << 3; // binary: 101000,or 40 in decimal int c = b >> 3; // binary: 101, or back to 5 like we started with When you left shift a value x by y bits (x << y), the leftmost y bits in x are lost, literally shifted out of existence. We’ll do this example with char values (which are integers in the range 0-255, and take up 8 bits of memory): char a = 5; // binary (all 8 bits): 00000101 char b = a << 7; // binary: and it is also used as insertion operator which use to insert value and it is also used with cout to print the value at console ex:- int a, b; a=5; b=++a; cout<<b // it will print the value of b which is 6 after increment by 1 as instructions are made in program
1st Dec 2017, 5:11 PM
GAWEN STEASY
GAWEN STEASY - avatar
+ 6
From the little I know about c++ you use << when using cout to output and >> we hen using cin to accept input
1st Dec 2017, 5:00 PM
᠌᠌Code X
᠌᠌Code X - avatar
+ 1
when you begin the sentence
22nd Apr 2018, 8:39 PM
Dayla