C Saved Program: fragrant-palace

facebook share

Here's the online compiler accompanied with IDE at your service. This is a saved code by one of our users. Try it out or save your own from the IDE page and don't forget to leave a feedback. You can find that at the bottom of the page.


/*#include <stdio.h>

float diameter(float d);
float circumference(float c);
float area(float a);
float r;
const float p=3.14;

int main()
{
    printf("Enter the radius of the circle:\n");
    scanf("%f", r);
    printf("Diameter of the circle is %.2f\n", diameter(d));
    printf("Circumference of the circle is %.2f\n", circumference(c));
    printf("Area of the Circle is %.2f", area(a));
    return 0;
}
float diameter(float d)
{
    float    d = r*2;
    return d;
}
float circumference(float c)
{
    float c;
    c = 2*p*r;
    return c;
}
float area(float a)
{
    float a;
    a = p*r*r;
    return a;
}
*/

#include<stdio.h>
float Diamtr (float r); float Circum (float r); float Surface (float r);	//set of function prototypes.
const float pi= 3.14;	//constant variables.
int main (void) {
	float rad=0;	//declaring variables for main func.
	printf ("PLEASE ENTER THE VALUE OF THE RADIUS(cm):  \n");
	scanf ("%f", &rad); //assign to rad
	//using functions to determine properties.
	printf ("\nDIAMETER = %.3fcm\nCIRCUMFERENCE = %.3fcm\nAREA = %.3f((cm)^2)\n\n(pi is taken as 3.14)\n\n", Diamtr(rad), Circum(rad), Surface(rad));
return 0;
} //end function main

float Diamtr (float r) { //function to calculate Diameter
	float Dia = (2*r);
	return(Dia);
} //end func. Diamtr
float Circum (float r) { //function to calculate Circumference
	float cir = (2*pi*r);
	return(cir);
} //end func. Circum
float Surface (float r) { //function to calculate Area.
	float sur = (pi*r*r);
	return(sur);
} //end func. Surface
Execute

Output

Press the execute button or CTRL + enter to run code.

Inputs