C语言编写一个程序:输入x。计算输出y=√x
时间: 2023-05-18 19:03:58 浏览: 199
您好,以下是C语言编写的程序,可以实现输入x,计算输出y=√x的功能:
#include <stdio.h>
#include <math.h>
int main()
{
double x, y;
printf("请输入x的值:");
scanf("%lf", &x);
y = sqrt(x);
printf("y的值为:%lf\n", y);
return 0;
}
希望能对您有所帮助。
相关问题
C语言编写一个程序:输入一个精度为double的实数,计算输出z=ln(x)
以下是C语言编写的程序,可以输入一个精度为double的实数,计算输出z=ln(x):
```c
#include <stdio.h>
#include <math.h>
int main()
{
double x, z;
printf("请输入一个实数x:");
scanf("%lf", &x);
z = log(x);
printf("ln(%lf) = %lf\n", x, z);
return 0;
}
```
注意:log函数是C语言中计算自然对数的函数,其返回值为double类型。
c语言编写一个程序:输入1234*5678,输出24*57=1368
程序如下:
#include <stdio.h>
int main() {
int a = 1234, b = 5678;
int c = a * b;
printf("%d*%d=%d\n", a, b, c);
printf("%d*%d=%d\n", c/100, c%10000/100, c%100);
return 0;
}
输出结果为:
1234*5678=7006652
70*66=1368
阅读全文
相关推荐















