任务和代码
/*
*Copyright ©2017,CSDN学院
*All rights reserved.
*文件名称:main.c
*作 者:LP
*完成日期:2017年10月11日
*版 本 号:visual studio 2015
*问题描述:输入3个双精度实数,分别求出它们的和、平均值、平方和以及平方和的开方,并输出所求出各个值。
*/
#include<stdio.h>
#include<math.h>
int main()
{
double a, b, c, sum, ave, sum_square, prescibe;
printf("Enter three double numbers:");
scanf("%lf %lf %lf", &a, &b, &c);
sum = a + b + c;
ave = sum / 3.0;
sum_square = pow(a, 2) + pow(b, 2) + pow(c, 2);
prescibe = sqrt(sum_square);
printf("sum=%lf ave=%lf sum_square=%lf prescibe=%f", sum, ave, sum_square, prescibe);
return 0;
}
运行结果
心得
这里面用到了math头文件,math.h头文件里面包含了很多数学的运算指令