1、【源程序 1】大小写转换示例。#include main()char c1,c2;scanf(“%c“,printf(“%c,%dn“,c1,c1);c2=c1+32;printf(“%c,%dn“,c2,c2);getch();【源程序 2】求三角形的面积。#include main() float a,b,c,s,area;scanf(“%f,%f,%f“,s=1.0/2*(a+b+c);area=sqrt(s*(s-a)*(s-b)*(s-c);printf(“%fn“,area);getch(); 3,4,5修改后#include main() float a,b,c,s,area;s
2、canf(“%f%f%f“,s=1.0/2*(a+b+c);area=sqrt(s*(s-a)*(s-b)*(s-c);printf(“%fn“,area);getch();3 4 5再修改#include main()float a,b,c,s,area;scanf(“%f%f%f“,if(a+bcarea=sqrt(s*(s-a)*(s-b)*(s-c) ;printf(“area=%6.2fn“,area);elseprintf(“It is not a trilateral.“);getch();【源程序 3】逻辑运算符短路求值示例。#includemain()int a=1,b=2,
3、c=3,d=4,m=1,n=1;int x;x=(m=ab)printf(“x=%dn3“,x);printf(“m=%d,n=%dn“,m,n);getch();修改后#includemain()int a=1,b=2,c=3,d=4,m=1,n=1;int x;x=(m=ab)printf(“x=%dn“,x);printf(“m=%d,n=%dn“,m,n);getch();【源程序 4】if 语句语法 1 结构用法示例。#include main() int a,b;scanf (“%d%d“,if(amain() char ch;scanf(“%c“,if(ch=ascanf(“%c“,if (c=0scanf(“%f“,if (x0) y=-1;else if (x=0) y=0;else y=1;printf(“x=%f,y=%2.0fn“,x,y);getch();