Just wanted to share my accomplishment!
Some may think this is nothing, but I am excited!! For the past several hours I have been playing with the C programming language. This is for school but if anyone has suggestions, tips, or general educational help while I finish up this semester I am all ears!
Below is a program which will give you the area of a circle
#include
int main()
{
int r;
double pi;
pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286;
printf( "Please enter the radius: " );
scanf( "%d", &r );
printf( "You entered %din as your radious\r\n", r );
double area = r * r * pi;
printf ("The area of your circle is %fin\r\n", area);
printf ("Hit enter to end program.\r\n");
getchar();
getchar();
return 0;
}
Comments
Sorry, I know this is a LEGO forum but I have been doing this ALL day and wanted to share my boring code to those who get this.
#include
int main()
{
float r;
double pi;
pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286;
do {
printf( "Enter Radius (ZERO to quit): " );
scanf( "%f", &r );
if ( r <= 0) {
return 1;
}
double area = r * r * pi;
printf ("The area of your circle is %fin\r\n", area);
}while ( r > 0 );
return 0;
getchar();
getchar();
return 0;
}
... realised i cant read c programming...
...who cares