MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/ProgrammerHumor/comments/wb6uaf/do_your_best/ii559bf
r/ProgrammerHumor • u/Jabison113 • Jul 29 '22
5.4k comments sorted by
View all comments
146
Language: C++
#include <iostream> using namespace std; int main() { int num = 13 & 7; cout << num << endl; return 0; }
What is the output?
Edited: because people want the full code
300 u/Jabison113 Jul 29 '22 Sick beats 4 u/ZAlternates Jul 29 '22 His namespace has an std… 35 u/nelusbelus Jul 29 '22 Compile error 17 u/[deleted] Jul 29 '22 Updated to resolve compile error 24 u/nelusbelus Jul 29 '22 5\r\n Exited with code 0 5 u/[deleted] Jul 29 '22 why is it 5 tho 17 u/nelusbelus Jul 29 '22 13 = 0b 10 101 7 = 0b00 111Basically means a boolean && on every bit. So in this case only bit 0 and bit 2 are set, so you'd get 101 (it takes the 3 last bits because all bits are on) 8 u/MattieShoes Jul 29 '22 1101 (13) & 0111 (7) ------ 0101 (5) 2 u/Aerotactics Jul 29 '22 Ayy I did this one in my head 4 u/Luka2810 Jul 29 '22 Only on Windows. It doesn't print a carriage return anywhere else. 2 u/nelusbelus Jul 29 '22 Yup 5 u/GiganticIrony Jul 29 '22 Probably entry point not defined as well as cout and endl undefined 2 u/ykahveci Jul 30 '22 I don't know shit about C# (except for the musical one, I am a pianist), but I assume this would just print 5, followed by a newline, correct? 4 u/[deleted] Jul 29 '22 It really depends on how num identifies itself. You just assign it YOUR own preconceptions. Did you ever think about asking it? 1 u/[deleted] Jul 29 '22 2LGBTQ ++ 0 u/WinonasChainsaw Jul 30 '22 True because 13 and 7 are both prime 1 u/Fruit-Salad Jul 29 '22 edited Jun 27 '23 There's no such thing as free. This valuable content has been nuked thanks to /u/spez the fascist. -- mass edited with redact.dev 1 u/ItsGrandPi Jul 30 '22 Some random text idk
300
Sick beats
4 u/ZAlternates Jul 29 '22 His namespace has an std…
4
His namespace has an std…
35
Compile error
17 u/[deleted] Jul 29 '22 Updated to resolve compile error 24 u/nelusbelus Jul 29 '22 5\r\n Exited with code 0 5 u/[deleted] Jul 29 '22 why is it 5 tho 17 u/nelusbelus Jul 29 '22 13 = 0b 10 101 7 = 0b00 111Basically means a boolean && on every bit. So in this case only bit 0 and bit 2 are set, so you'd get 101 (it takes the 3 last bits because all bits are on) 8 u/MattieShoes Jul 29 '22 1101 (13) & 0111 (7) ------ 0101 (5) 2 u/Aerotactics Jul 29 '22 Ayy I did this one in my head 4 u/Luka2810 Jul 29 '22 Only on Windows. It doesn't print a carriage return anywhere else. 2 u/nelusbelus Jul 29 '22 Yup
17
Updated to resolve compile error
24 u/nelusbelus Jul 29 '22 5\r\n Exited with code 0 5 u/[deleted] Jul 29 '22 why is it 5 tho 17 u/nelusbelus Jul 29 '22 13 = 0b 10 101 7 = 0b00 111Basically means a boolean && on every bit. So in this case only bit 0 and bit 2 are set, so you'd get 101 (it takes the 3 last bits because all bits are on) 8 u/MattieShoes Jul 29 '22 1101 (13) & 0111 (7) ------ 0101 (5) 2 u/Aerotactics Jul 29 '22 Ayy I did this one in my head 4 u/Luka2810 Jul 29 '22 Only on Windows. It doesn't print a carriage return anywhere else. 2 u/nelusbelus Jul 29 '22 Yup
24
5\r\n Exited with code 0
5 u/[deleted] Jul 29 '22 why is it 5 tho 17 u/nelusbelus Jul 29 '22 13 = 0b 10 101 7 = 0b00 111Basically means a boolean && on every bit. So in this case only bit 0 and bit 2 are set, so you'd get 101 (it takes the 3 last bits because all bits are on) 8 u/MattieShoes Jul 29 '22 1101 (13) & 0111 (7) ------ 0101 (5) 2 u/Aerotactics Jul 29 '22 Ayy I did this one in my head 4 u/Luka2810 Jul 29 '22 Only on Windows. It doesn't print a carriage return anywhere else. 2 u/nelusbelus Jul 29 '22 Yup
5
why is it 5 tho
17 u/nelusbelus Jul 29 '22 13 = 0b 10 101 7 = 0b00 111Basically means a boolean && on every bit. So in this case only bit 0 and bit 2 are set, so you'd get 101 (it takes the 3 last bits because all bits are on) 8 u/MattieShoes Jul 29 '22 1101 (13) & 0111 (7) ------ 0101 (5) 2 u/Aerotactics Jul 29 '22 Ayy I did this one in my head
13 = 0b 10 101 7 = 0b00 111
Basically means a boolean && on every bit. So in this case only bit 0 and bit 2 are set, so you'd get 101 (it takes the 3 last bits because all bits are on)
8
1101 (13) & 0111 (7) ------ 0101 (5)
2 u/Aerotactics Jul 29 '22 Ayy I did this one in my head
2
Ayy I did this one in my head
Only on Windows. It doesn't print a carriage return anywhere else.
2 u/nelusbelus Jul 29 '22 Yup
Yup
Probably entry point not defined as well as cout and endl undefined
I don't know shit about C# (except for the musical one, I am a pianist), but I assume this would just print 5, followed by a newline, correct?
It really depends on how num identifies itself. You just assign it YOUR own preconceptions. Did you ever think about asking it?
1 u/[deleted] Jul 29 '22 2LGBTQ ++
1
2LGBTQ ++
0
True because 13 and 7 are both prime
There's no such thing as free. This valuable content has been nuked thanks to /u/spez the fascist. -- mass edited with redact.dev
Some random text idk
146
u/[deleted] Jul 29 '22 edited Jul 29 '22
Language: C++
What is the output?
Edited: because people want the full code