1 / 14
文档名称:

C语言 实验报告.doc

格式:doc   大小:87KB   页数:14页
下载后只包含 1 个 DOC 格式的文档,没有任何的图纸或源代码,查看文件列表

如果您已付费下载过本站文档,您可以点这里二次下载

分享

预览

C语言 实验报告.doc

上传人:zhangkuan1436 2018/5/25 文件大小:87 KB

下载得到文件列表

C语言 实验报告.doc

相关文档

文档介绍

文档介绍:C语言程序设计(B)
(2010-2011-2)
实验报告
教学班级: 学号: 姓名:
课程教师: 实验辅导教师:
自由编辑的程序
一、实验前的源程序:
//任意整数的叠加
#include<>
void main()
{
int i,j,sum=0;
printf("please input a int number\n");
scanf("%d",&j)
for(i=0;i<=j;i++)
sum=sum+i;
printf("此数的叠加=%d\n",sum);
}
实验错误报告:
[Error] D:\Program Files\C-Free 4\temp\:7: parse error before `for'
[Error] D:\Program Files\C-Free 4\temp\:7: parse error before `)'
构建中止未命名10: 2 个错误, 0 个警告
实验后的源程序:
//任意整数的叠加
#include<>
void main()
{
int i,j,sum=0;
printf("please input a int number\n");
scanf("%d",&j);
for(i=0;i<=j;i++)
sum=sum+i;
printf("此数的叠加=%d\n",sum);
}
二、实验前的源程序:
/*小写字母转大写字母*/
#include<>
void main()
{
char c1,c2;
c1='w';
c2='s';
c1=c1-32;
c2=c2-32;
printf("%c,%c\n",c1,c);
}
实验错误报告:
[Error] D:\Program Files\C-Free 4\temp\:9: `c' undeclared (first use this function)
[Error] D:\Program Files\C-Free 4\temp\:9: (Each undeclared identifier is reported only once
[Error] D:\Program Files\C-Free 4\temp\:9: for each function it appears in.)
构建中止未命名11: 3 个错误, 0 个警告
实验后的源程序:
/*小写字母转大写字母*/
#include<>
void main()
{
char c1,c2;
c1='w';
c2='s';
c1=c1-32;
c2=c2-32;
printf("%c,%c\n",c1,c2);
}
三、实验前的源程序:
/*查看某一年是否为闰年*/
#include <>
void main()
{
int year,i;
scanf("%d",&year);
if(year%4==0)
{
if(year%100==0)
{
if(year%400==0)
i=1;
else
i=0;
}
else
i=1;
}
else
i=0;
if(i)
printf("%d 是闰年\n",year);
else
printf("%d 不是闰年\n",year);
}
实验错误报告:
[Error] D:\Program Files\C-Free 4\temp\:15: parse error before `else'
[Error] D:\Program Files\C-Free 4\temp\:25: parse error at end of input
构建中止未命名14: 2 个错误, 0 个警告
实验后的源程序:
/*查看某一年是否为闰年*/
#include <>
void main()
{
int year,i;
scanf("%d",&year);
if(year%4==0)
{
if(year%100==0)
{
if(year%400==0)
i=1;
else
i=0;
}
else
i=1;
}
else
i=0;
if(i)
printf("%d 是闰年\n",year);
e