关于c语言的一些初级问题

来源:百度知道 编辑:UC知道 时间:2024/06/03 10:42:23
#include<math.h>
#include<stdio.h>
main()
{
double x,s;
printf("input number:\n");
scanf("%lf",&x);
s=sin(x);
printf("sine of %lf is %lf\n",x,s);
}
请问上面的代码有问题吗?如果没有,按这种格式写在tc里会运行吗?
我自己试过了,好像运行不了,需要注意什么吗?哪怕一丁点的细节也请告诉我。还有是不是我运行的时候出问题了,应该怎样运行?
我是刚刚接触c的,麻烦你们帮帮我

程序没有问题。
#include <math.h> -- 我习惯要加一个空格
#include <stdio.h> -- 我习惯要加一个空格

void main() -- 用 void, 则不需要有 return 语句
scanf("%lf",&x); -- x 以弧度计,例如给 0.5236 (30度)

printf("sine of %lf is %lf\n",x,s); 后面,程序结束前 加
system("PAUSE"); -- 加暂停,以便观察程序运行结果。有些人喜欢用 getchar()来暂停
}

程序没问题 你唯一需要注意的是输入那个是弧度角而不是 角度

程序没有问题,我用VC检查过了。
记住输入的是弧度制就可以了

L_o_o_n_i_e 回答的很好,我就不答了。

注意输入的数的形式