online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code   
Language
#include<stdio.h> long double myFloor(long double x) /* Change this to your liking: long double might be float in your situation. */ { long double xcopy=x<0?x*-1:x; unsigned int zeros=0; long double n=1; for(n=1;xcopy>n*10;n*=10,++zeros); for(xcopy-=n;zeros!=-1;xcopy-=n) if(xcopy<0) { xcopy+=n; n/=10; --zeros; } xcopy+=n; return x<0?(xcopy==0?x:x-(1-xcopy)):(x-xcopy); } int main(){ long double n; while(1){ printf("Enter a number to floor: "); scanf("%Lf", &n); printf("%.2Lf\n", myFloor(n)); } }

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