像这样的东西:
/*Simple program to calculate the circumference of a circle. */
#include <stdio.h>
#define PI 3.14159
int main()
{
float r1 /*R1 being the radius.*/
/* Since the Circumference is R * PI * 2, or R2 * PI */
/* we do the following */
printf("This is a program that calculates the Circumference\n");
printf("Of a circle. Please enter your radius.\n");
scanf("%f", r1"\n"); /*This being the first number.*/
printf("Your radius times PI times 2 is\n");
/*Now it calculates the circumference. */
printf("%f", (r1 * PI * 2)"\n");
}
我也会使用 C 来做数学的东西,所以任何关于它的内幕都会有所帮助。例如,我想知道是否可以将#define
Pi作为一个数字或任何类似性质的常数,然后在 True/False 语句中使用它。任何帮助,将不胜感激。