实验课素材
实验1
1 #include<stdio.h> 2 int main() 3 { 4 int a,b,sum; 5 a=123; 6 b=456; 7 sum=a+b; 8 printf("sum is %d",sum); 9 return 0; 10 }
实验2.1
1 #include<stdio.h> 2 int main() 3 { 4 char c1,c2; 5 c1=97; 6 c2=98; 7 printf("c1=%c,c2=%c\n",c1,c2); 8 printf("c1=%d,c2=%d\n",c1,c2); 9 return 0; 10 }
实验2.2
1 #include<stdio.h> 2 int main() 3 { 4 char c1,c2; 5 c1=197; 6 c2=198; 7 printf("c1=%c,c2=%c\n",c1,c2); 8 printf("c1=%d,c2=%d\n",c1,c2); 9 return 0; 10 }
实验3.1
实验3.2
1 #include<stdio.h> 2 int main() 3 { 4 5 long double z; 6 float x,y,d; 7 scanf("%f%f",&x,&y); 8 if(y>0){ 9 d=1/y; 10 }else {d=-(1/y);} 11 z=x+d; 12 printf("%e",z); 13 }
实验3.3
1 #include<stdio.h> 2 int main() 3 { 4 float x,y,d,z; 5 scanf("%f%f",&x,&y); 6 if(y>0){ 7 d=1/y; 8 }else {d=-(1/y);} 9 z=x+d; 10 printf("%e",z); 11 }