资源描述:
《c语言上机实验完整问题详解》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、实用标准实验一自测练习1程序代码#include"stdio.h"voidmain(){intx;scanf("%d",&x);if(x%2!=0)printf("%disanodd",x);elseprintf("%disaneven",x);}运行结果自测练习2程序代码#include"stdio.h"voidmain(){inti,sum;i=1;sum=0;while(i<=100){sum=sum+i;i++;}文档大全实用标准printf("sum=%d",sum);}运行结果自测练习3程序代码#include"stdio.h"voidmain(){i
2、nti,n;longp;p=1;printf("Entern:");scanf("%d",&n);for(i=1;i<=n;i++)p=p*i;printf("p=%ld",p);}运行结果文档大全实用标准自测练习4程序代码#include"stdio.h"intmax(intx,inty){intz;if(x>y)z=x;elsez=y;return(z);}voidmain(){inta,b,c;scanf("%d,%d",&a,&b);c=max(a,b);printf("max=%d",c);}运行结果文档大全实用标准自测练习5程序代码#include"std
3、io.h"voidmain(){intx,y;for(x=0;x<=25;x++)for(y=0;y<=50;y++)if(4*x+y*2==100)printf("兔=%d,鸡=%",x,y);}运行结果文档大全实用标准#include(stdio.h)voidmain(){inta=5;doublex;printf("%d%d",sizeof(int),sizeof(a));printf("%d%d",sizeof(double),sizeof(x));printf("%d%d",sizeof(float),sizeof(char));}实验二自测练习一程序代码#
4、include(stdio.h)voidmain(){inta=5;doublex;printf("%d%d",sizeof(int),sizeof(a));printf("%d%d",sizeof(double),sizeof(x));文档大全实用标准printf("%d%d",sizeof(float),sizeof(char));}运行结果自测练习二程序代码#include(stdio.h)voidmain(){inta=5;printf("%d%d",a,a++);}运行结果自测练习三程序代码#include(stdio.h)voidmain(){inta,b
5、,c;a=1;b=2;c=3;printf("%dt%d%d%d%dtb%d",a,b,c,a,b,c);文档大全实用标准}运行结果实验三程序代码#includevoidmain(){intx,h,y,m,s;printf("inputx:");scanf("%d",&x);h=x/3600;y=x%3600;m=y/60;s=y%60;printf("%d小时%d分钟%d秒",h,m,s);}运行结果文档大全实用标准程序代码#includevoidmain(){chara,b,c;printf("inputx:");b=
6、getchar();a=b-1;c=b+1;printf("%c,%c,%c,",a,b,c);}运行结果文档大全实用标准程序代码#include#includevoidmain(){intx;printf("input:");scanf("%d",&x);printf("八进制:%o",x);printf("十六进制:%x",x);}文档大全实用标准运行结果程序代码#include#definep3.1415926voidmain(){floatr,h,v;printf("输入r:");scanf("%f",&r);pri
7、ntf("输入h:");scanf("%f",&h);v=p*r*r*h;printf("v=%f",v);}文档大全实用标准运行结果程序代码#include#includevoidmain(){floatx,y,z,w;printf("本金x,存款年限y,年利率z");scanf("%f,%f,%f",&x,&y,&z);w=x*y*z;printf("利息=%lf",w);}文档大全实用标准运行结果实验四自测一程序代码#include"stdio.h"voi