online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code    Language
#include <stdio.h> int sar (int x, int n) { int s = -((unsigned) x >> 31); // ensure logical right shift return (s^x) >> n ^ s; }; int main(){ int x=-5, n=1; printf("logical right shift: unsigned(%d) >> %d = %d\n", x, n, (unsigned)x >> n); printf("builtin right shift: %d >> %d = %d\n", x, n, x >> n); printf("arithmetic right shift: sar(%d, %d) = %d", x, n, sar(x, n)); return 0; }

Compiling Program...

Command line arguments:
Standard Input: Interactive Console Text
×

                

                

Program is not being debugged. Click "Debug" button to start program in debug mode.

#FunctionFile:Line
VariableValue
RegisterValue
ExpressionValue