+ 15

Please anyone can explain me this c++ program ?

#include<iostream.h> #include<conio.h> void main() { clrscr(); int a,b; a=5; b&=a; //point of interest to know cout<<b; getch(); } I want to know why and how its output arrives 4.

29th Apr 2017, 4:05 PM
Jay Tailor
Jay Tailor - avatar
7 Answers
+ 18
Porting it over to standard C++, #include<iostream> int main() { int a,b; a = 5; b &= a; std::cout<<b; return 0; } '&=' is the bitwise AND assignment operator. What it does, is to perform a bitwise AND operation and then assign the value to b.
29th Apr 2017, 4:13 PM
Hatsy Rei
Hatsy Rei - avatar
+ 15
Thanks 😀
29th Apr 2017, 4:15 PM
Jay Tailor
Jay Tailor - avatar
+ 11
it will print the contact of variable "b" on output window
7th Aug 2017, 4:04 PM
Jay Tailor
Jay Tailor - avatar
9th Aug 2017, 4:05 AM
Hatsy Rei
Hatsy Rei - avatar
+ 9
How does these bitwise operators work?
29th Apr 2017, 9:39 PM
Luyanda
Luyanda - avatar
+ 2
explain sir.. std::cout<<b
7th Aug 2017, 2:01 PM
Pawan Kumar
Pawan Kumar - avatar
+ 1
std:: why written
9th Aug 2017, 4:03 AM
Pawan Kumar
Pawan Kumar - avatar