Last active
August 29, 2015 14:00
-
-
Save mr-fool/dc291383cde1830c974f to your computer and use it in GitHub Desktop.
Calculating the diameter, circumference and area of a circle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*Calculate the diameter,circumference and area of a circle | |
Using C pi*/ | |
/*Including Library*/ | |
#include <math.h> | |
#include <stdio.h> | |
int main (void) { | |
/*Declaring the variable*/ | |
int radius; | |
int diameter; | |
int area; | |
int circumference; | |
printf("Please enter the radius of the circle\n"); | |
scanf("%d", &radius); /*reading radius*/ | |
printf("The radius is %d", radius); | |
/*Calculation part*/ | |
diameter = radius * 2; | |
area = M_PI * (radius *radius); /*pi *r^2*/ | |
circumference = 2* M_PI * radius; /*2pir*/ | |
printf("\t The diameter is %d\n", diameter); | |
printf("The area is %d\n", area); | |
printf("The circumference is %d\n", circumference); | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
allFiles: Circle.c | |
gcc -Wall Circle.c -o Circle.out -lm | |
clean: | |
rm *.o Circle.out |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment