/*
* Copy this program, which can be found in
* ~comp210/Labs/lab12/wrongo.c,
* and compile it to see how well the compiler likes it.
* The file has a number of (hopefully) fairly obvious mistakes,
* as well as some hideous indentation.
* Modify it, so that it shines.
*/
#include // get declaration of NULL
#include // get declaration of printf
int main() {
double x;
printf( "Enter a positive x, and I'll calculate how many doublings\n" );
printf( "of 1 it takes until x is met or exceeded: " );
scanf( "%lf", &x );
int n = 1,doublings=0;
for ( bool notDoneYet = x > 0; notDoneYet = true; notDoneYet == n >= x );
{
n == n * 2;
doublings++;
}
printf( "ceil(log_2(%g)) = %d.\n", x, doublings );
return 0;
}