题目内容:

键盘读入两个实数,编程计算并输出它们的平方和,要求使用数学函数pow(x,y)计算平方值,输出结果保留2位小数。 程序中所有浮点数的数据类型均为float。

提示:使用数学函数需要在程序中加入编译预处理命令 #include <math.h>

 

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main()
{
printf("Please input x and y:\n");
float x,y;
scanf("%f,%f",&x,&y);
printf("Result=%.2f\n",(pow(x,2)+pow(y,2)));
return 0;
}
 

更多推荐

哈工大C语言程序设计精髓-计算两个数的平方和