C语言编程 初级

来源:百度知道 编辑:UC知道 时间:2024/06/21 17:00:43
编程求y=cos(根号下(a+x)) + e的ax次方
要求a和x要键盘输入

#include"stdio.h"
#include"math.h"
void main()
{
float a,x,y;
printf("Please input a and x\n");
scanf("%f %f",a,x);
y=cos(sqrt(a+x))+e^a*x
printf("%f",y);
}

总是编译时执行linc出错 请帮忙修改

scanf("%f%f",&a,&x)
两个 %f间不能有空格 ,&a,&x

#include"stdio.h"
#include"math.h"
void main()
{
float a,x,y;
printf("Please input a and x\n");
scanf("%f %f",&a,&x);
y=cos(sqrt(a+x))+exp(a*x);/*这里要用函数exp求e的ax次方*/
printf("%f",y);
}

scanf("%f%f",a,x)
a 和 x 的前面要有 &

都忘光了,是不是要scanf("%f%f",&a,&x);