• Courses
  • Code Compiler
  • Discuss
  • Pricing
  • Teams
Menu
0

I wrote this code and result is -6. Can someone explain why?

#include<iostream> using namespace std; int main() { int x=5; cout<<~x; return 0; }

c++
12th Aug 2018, 8:57 AM
Ayan Biswas
Ayan Biswas - avatar
1 Answer
+ 2
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Bitwise_Operators http://www.learncpp.com/cpp-tutorial/38-bitwise-operators/ ~ inverts the bits example ~ 1010 = 0101
12th Aug 2018, 9:29 AM
B K

Often have questions like this?

Learn more efficiently, for free:

  • Introduction to Python

    7.1M learners

  • Introduction to Java

    4.7M learners

  • Introduction to C

    1.5M learners

  • Introduction to HTML

    7.5M learners

See all courses
Hot today
[ReSolved] Still No Intergalactic Champion Badge?
1 Votes
Infinite Loop Trap on JavaScript
2 Votes
Why there are many programming language ??
2 Votes
I have been at it for hours and just got totally stuck on the chat bot v1.1 very first problem got me stuck.
0 Votes
Can I get my banned account from sl back i got like 3 months banned/blocking
0 Votes
HOW CAN I CODE FASHION STYLIST USING JAVA?
1 Votes
Data Structure And Algorithm
2 Votes
How to remember coding
1 Votes
Help
0 Votes
Future Talk
1 Votes