1. 怎麼用c語言計算圓周長和面積
代碼如下:
#include<stdio.h>
int main(){
int radius;
float area,perimeter;
radius=6;
perimeter=2*3.14*radius;
printf("圓的周長=%f英寸 ",perimeter);
area=3.14*radius*radius;
printf("圓的面積=%f平方英寸 ",area);
return(0);
}
2、c語言計算矩形的周長和面積
#include<stdio.h>
/*長方形的高和寬,單位為米*/
int width;
int height;
int area;
int perimeter;
int main(){
height=7;
width=5;
perimeter=2*(height+width);
printf("矩形的周長=%d米 ",perimeter);
area=height*width;
printf("矩形的面積=%d平方米 ",area);
return(0);
}
(1)如何用c語言編程求操場面積擴展閱讀:
使用C語言計算圓周長和面積的優勢:
1、簡潔緊湊、靈活方便
C語言一共只有32個關鍵字,9種控制語句,程序書寫形式自由,區分大小寫。把高級語言的基本結構和語句與低級語言的實用性結合起來。C語言可以像匯編語言一樣對位、位元組和地址進行操作,而這三者是計算機最基本的工作單元。
2、運算符豐富
C語言的運算符包含的范圍很廣泛,共有34種運算符。C語言把括弧、賦值、強制類型轉換等都作為運算符處理。從而使C語言的運算類型極其豐富,表達式類型多樣化。靈活使用各種運算符可以實現在其它高級語言中難以實現的運算。
2. C語言函數求面積
哥們 你main函數漏了一句, 你的r在調用shubanjing()時輸入,但你main函數沒調用shubanjing(),也沒定義r。
void main()
{
float mianji;
double r = shubanjing();//就這一句
mianji=qiumianji(r);//這里參數是r
printf("你所求三角形面積為:%f",mianji);
}
main函數沒有定義你也沒有輸入r怎麼能算出面積呢 ?
3. 怎麼用c語言計算圓周長和面積
一、數學公式:
圓周長=2*π*半徑
面積=π*半徑²
二、演算法分析:
周長和面積都依賴半徑,所以要先輸入半徑值,然後套用公式,計算周長和面積。
最終輸出結果即可。
三、參考代碼:
#include
#define pi 3.14159
int main()
{
double r, s, c;
scanf("%lf",&r);//輸入半徑。
s=pi*r*r;//計算面積。
c=2*pi*r;//計算周長
printf("面積=%lf 周長=%lf\n", s,c);//輸出結果
return 0;
}
4. 怎麼用C語言編程設計「輸入長方形的長和寬,求長方形的面積」的程序
需要准備的材料分別有:電腦、C語言編譯器。
1、首先,打開C語言編譯器,新建一個初始.cpp文件,例如:test.cpp。
5. 用C語言編譯程序:求面積
#include <iostream>
#include <iomanip> // 要這個頭文件
#include <math.h>
using namespace std;
const double PI=3.141593;
// 3 個函數:
void area(double a, double &s) {
s = PI * a * a;
}
void area(double a, double b,double &s) {
s = a * b;
}
void area(double a, double b, double c, double &s) {
double d;
d = (a+b+c) / 2.0;
s = sqrt(d*(d-a)*(d-b)*(d-c)) ;
}
void showmenu()
{
cout<<endl<<"choice 1:triangle"<<endl;
cout<<"choice 2:rectangle"<<endl;
cout<<"choice 3:round"<<endl;
cout<<"choice 0:exit"<<endl;
cout<<"input your choice:"<<endl;
}
int main()
{int a,b,c;
char choice;
double s;
showmenu();
cin>>choice;
while (choice!='0')
{switch (choice)
{case '1':cout<<"input the triangle's 3 side length:"<<endl;
cin>>a>>b>>c;
area(a,b,c,s);
break;
case '2':cout<<"input the rectangle's length and width:"<<endl;
cin>>a>>b;
area(a,b,s);
break;
case '3':cout<<"input the round's radius:"<<endl;
cin>>a;
area(a,s);
}
cout<<"area="<< setiosflags(ios::fixed)<<setprecision(2)<<s<<endl;
showmenu();
cin>>choice;
}
return 0;
}
6. 用c語言編程求出圓的周長、和面積是多少。
程序代碼如下:
(6)如何用c語言編程求操場面積擴展閱讀:
圓周長是指在圓中內接一個正n邊形,邊長設為an,正邊形的周長為n*an,當n不斷增大的時候,正邊形的周長不斷接近圓的周長C的數學現象,即:n趨近於無窮,C=n*an。
圓面積公式是一種定理定律。為圓周率*半徑的平方,用字母可以表示為:S=πr²或S=π*(d/2)²。(π表示圓周率,r表示半徑,d表示直徑)。
圓周率(Pi)是圓的周長與直徑的比值,一般用希臘字母π表示,是一個在數學及物理學中普遍存在的數學常數。π也等於圓形之面積與半徑平方之比。是精確計算圓周長、圓面積、球體積等幾何形狀的關鍵值