[C programming] Set the circle radius r=1.5, cylinder height h=3, calculate the circumference, circle area, spherical surface area, spherical area, cylinder volume.

Use C language to design a program to realize, set the radius of the circle r=1.5, and the height of the cylinder h=3, find the circumference of the circle, the area of ​​the circle, the surface area of ​​the sphere, the area of ​​the sphere, and the volume of the cylinder. Use scanf to input data and output calculation results, and text description is required when outputting.

The source code is as follows:

#include <stdio.h>
int main()
{
    float r=1.5,h=3,pi=3.14,c,s,qs,qv,zv;
    c=2*pi*r;               //求圆周长
    s=pi*r*r;               //求圆面积
    qs=4*pi*r*r;            //求圆球表面积
    qv=4/3*pi*r*r*r;        //求圆球体积
    zv=h*s;                 //求圆柱体积
    printf("圆周长=%f\n圆面积=%f\n圆球表面积=%f\n圆球体积=%f\n圆柱体积=%f\n",c,s,qs,qv,zv);
    return 0;
}

The test run results are as follows:

 

Guess you like

Origin blog.csdn.net/weixin_61536532/article/details/121587604
Recommended