实验一
代码1:
#include "stdio.h" int main() { char c1,c2; c1=97; c2=98; printf("c1=%c,c2=%c\n",c1,c2); printf("c1=%d,c2=%d\n",c1,c2); return 0; }
代码2:
#include "stdio.h" int main () { printf("input two numbers:\n"); float x,y,z; scanf("%f%f",&x,&y); if(y<=0) y=-1*y; z=x+1/y; printf("the outcome is \n"); printf("%d\n",int(z));//不能直接使用“%d”,否则出现类型错误;或者使用"%.0f"输出 printf("%15.6f\n",z); printf("%e\n",z); return 0; }
代码3:
#include "stdio.h" int main() { int a,b,sum; a=123; b=456; sum=a+b; printf("sum is %d\n",sum); return 0; }
(ver1.0)