"C语言程序设计实验报告:运行环境、方法及实验步骤详解"

0 下载量 164 浏览量 更新于2024-03-24 收藏 767KB DOC 举报
本次实验旨在让学生熟悉C语言程序设计的环境和方法。实验环境为win7操作系统,使用的软件是vc 6.0。实验目标包括了解计算机系统的基本操作方法,学会独立使用系统;掌握编辑、编译、连接和运行一个C程序的方法;通过简单的C程序运行,初步了解C源程序的特点。 在实验中,我们首先运行了一个简单的C程序,让学生体验编译和运行的过程。接着,我们对程序进行了分析,讲解了每个部分的作用和逻辑。通过这个实例,学生对C程序的结构和语法有了初步的了解。同时,我们还对常见的编译错误进行了解释和分析,帮助学生更好地理解程序运行过程中可能出现的问题及解决方法。 通过本次实验,学生不仅掌握了C程序设计的基本操作方法,还加深了对C语言的理解和应用。这为今后的学习和实践打下了坚实的基础。experiment report on C programming The purpose of this experiment is to familiarize students with the environment and methods of C language programming. The experimental environment is win7 operating system, using the software vc 6.0. The objectives of the experiment include understanding the basic operation methods of the computer system, learning to independently use the system; mastering the method of editing, compiling, linking, and running a C program; and understanding the characteristics of C source programs through running simple C programs. In the experiment, we first ran a simple C program to allow students to experience the process of compiling and running. Then, we analyzed the program, explaining the function and logic of each part. Through this example, students have a preliminary understanding of the structure and syntax of C programs. At the same time, we also explained and analyzed common compilation errors, helping students better understand the problems that may arise during program execution and their solutions. Through this experiment, students not only mastered the basic operation methods of C programming but also deepened their understanding and application of the C language. This lays a solid foundation for future learning and practice.
2023-03-09 上传
C语言程序设计 "实"1.掌握结构体类型的概念和说明方法 " "验"2.掌握结构体变量的定义和引用。结构体类型变量成员的使用。 " "目"3.掌握结构体数组的定义和使用方法。 " "的"4.掌握指向结构体变量的指针变量的概念和应用。 " " "5.掌握结构变量与指向结构的指针作为函数参数实现函数的调用。 " " "6.掌握共用体的概念和说明方法。 " " "7.掌握共用体变量的定义和引用。共用体类型变量成员的使用 " " "8.掌握位运算的概念和方法。 " " "9.掌握位运算符(&,", ,~)的使用方法。 " " "10.了解有关位运算的算法。 " " "11.掌握枚举类型概念和说明方法 " " "12.掌握枚举类型变量的定义以及枚举类型变量的使用。 " " "1.建立一个学生的简单信息表,其中包括学号、年龄" " " "、性别及一门课的成绩。要求从键 " " " "盘输入数据,并显示出来。上机运行以下程序。 " " " "分析:一个学生信息表可以由结构体来定义,表中的 " " " "内容可以通过结构体中的成员来 " " " "表示。体会结构体成员的点运算符引用方法。 " " " "#include"stdio.h" " " "实"void main() " " " "{ " " "验"struct st " " " "{ " " "内"int num; " " " "int age; " " "容"char sex; " " " "float score; " " "与"}; " " " "struct st info; " " "步"printf("input number:"); " " " "scanf("%d",&info.num); " " "骤"printf("input age:"); " " " "scanf("%d",&info.age); " " " "getchar(); " " " "printf("input sex:"); " " " "scanf("%c",&info.sex); " " " "printf("input score:"); " " " "scanf("%f",&info.score); " " " "printf("number=%d\n",info.num); " " " "printf("age=%d\n",info.age); " " " "printf("sex=%c\n",info.sex); " " " "printf("score=%f\n",info.score); " " " "} " " " "2.建立 5 " " " "名学生的信息表,每个学生的数据包括学号、姓名及 " " " "一门课的成绩。要求从键盘 " " " "输入这 5 名学生的信息,并按照每一行显示一名学 " " " "生信息的形式将 5 名学生的信息显示出 " " " "来。上机运行以下程序。 " " " "分析:每个学生的数据学号、姓名及一门课的成绩用 " " " "结构体表示,5 名学生的信息表 " " " "用结构体数组表示,体会结构体数组元素的引用方法 " " " "。 " " " "#include"stdio.h" " " " "#define N 5 " " " "struct stud " " " "{ " " " "int num; " " " "char name [20]; " " "实"float score; " " " "}; " " "验"struct stud s[N]; " " " "void main() " " "内"{ " " " "int i; " " "容"for (i=0;i<N;i++) " " " "{ " " "与"printf("input number:"); " " " "scanf("%d",&s[i].num); " " "步"printf("input name:"); " " " "scanf("%s",s[i].name); " " "骤"printf("input score:"); " " " "scanf("%f",&s[i].score); " " " "} " " " "for (i=0;i<N;i++) " " " "{ " " " "printf("%d ",s[i].num); " " " "printf("%s ",s[i].name); " " " "printf("%f\n",s[i].score); " " " "} " " " "} " " " "3.显示某人工资信息的程序如下,分析显示结果。上 " " " "机运行以下程序。 " " " "分析:某人工资信息可以由结构体来定义,表中的内 " "