实验一
#include<stdio.h>
int main()
{
int a,b,sum;
a=123;
b=456;
sum=a+b;
printf("sum is %d\n",sum);
return 0;
}
2.分析下面程序。
#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;
}
将才c1改变为197,吃改变为198后
#include<stdio.h>
int main()
{
char c1,c2;
c1=197;
c2=198;
printf("c1=%c,c2=%c\n",c1,c2);
printf("c1=%d,c2=%d\n",c1,c2);
return 0;
}
3.输入x,y,编程程序z=x+1/|y|的值
#include<stdio.h>
int main()
{
float x,y,z;
scanf("%f,%f",&x,&y);
if (y>=0)
y=y;
else
y=-y;
z=x+1/y;
printf("整型z=%d,浮点数z=%15.6f,指数z=%e\n",(int)z,z,z);
return 0;
}