1.求三角形面积
#include<stdio.h>
#include<math.h>
int main()
{
double a,b,c,s,area;
a=3.67;
b=5.43;
c=6.21;
s=(a+b+c)/2;
area=sqrt(s*(s-a)*(s-b)*(s-c));
printf("a=%f\tb=%f\tc=%f\t");
printf("area=%f\n");
return 0;
}
运行结果
a=0.000000 b=0.000000 c=-1.#QNAN0 area=0.000000
--------------------------------
Process exited after 0.0094 seconds with return value 0
请按任意键继续. . .
2.输入球半径,求球体积
#include<stdio.h>
#include<math.h>
#define PI 3.14
int main()
{
float r,v;
printf("请输入半径r:");
scanf("%f",&r);
v=4*PI*pow(r,3)/3;
printf("%f",v);
return 0;
}
运行结果
请输入半径r:3
113.040001
--------------------------------
Process exited after 3.564 seconds with return value 0
请按任意键继续. . .
3.字母的大写转小写
#include<stdio.h>
int main()
{
char c1,c2;
c1='A';
c2=c1+32;
printf("%c,%c\n",c1,c2);
printf("%d,%d\n",c1,c2);
return 0;
}
运行结果
A,a
65,97
--------------------------------
Process exited after 0.01597 seconds with return value 0
请按任意键继续. . .