2009年10月13日 星期二

程式語言 debug 3

#include /* Standard Input/Output function declarations */
#include
int main( void )
{
float fRadius; /* Radius of circle */
float fArea; /* Area of circle */
/* [a] : Prompt User for "radius of circle" */
printf("============================================\n");
printf("Please input the circle radius (Radius > 0):");
scanf("%f", &fRadius);
/* [b] : Check that the radius in greater than zero */
if( fRadius <= 0 ) { printf("ERROR >> Circle radius must be greater than zero\n");
exit (1);
}
/* [c] : Compute Area of Circle */
fPi = 4.0*atan( 2.0 );
fArea = fPi*fRadius*fRadius;
/* [d] : Print Radius and Area */
printf("Radius of Circle = %8.3f \n", fRadius );
printf("Area of Circle = %8.3f \n", fArea );
return (0);

}

===============================================================================

#include /* Standard Input/Output function declarations */
#include

int main( void )
{
float fRadius; /* Radius of circle */
float fArea; /* Area of circle */
float fPi; /*Variable for "Pi" */
/* [a] : Prompt User for "radius of circle" */
printf("============================================\n");
printf("Please input the circle radius (Radius > 0):");
scanf("%f", &fRadius);
/* [b] : Check that the radius in greater than zero */
if( fRadius <= 0 ) { printf("ERROR >> Circle radius must be greater than zero\n");
exit (1);
}
/* [c] : Compute Area of Circle */
fPi = 4.0*atan( 1.0 );
fArea = fPi*fRadius*fRadius;
/* [d] : Print Radius and Area */
printf("Radius of Circle = %8.3f \n", fRadius );
printf("Area of Circle = %8.3f \n", fArea );
return (0);

}

沒有留言:

張貼留言