C语言基础教程:程序设计与面向对象解析

需积分: 15 1 下载量 109 浏览量 更新于2024-09-08 收藏 114B TXT 举报
"程序设计基础(C) 视频" 本文档是关于C语言程序设计的基础教程,旨在系统地介绍C语言的基本知识、语法和编程方法。它不仅教授C语言的语法,还结合面向对象的程序设计思想,帮助读者理解如何解决实际问题并用计算机语言进行描述。教程中的每个章节都有丰富的例题,用于解释基本概念,并在每章末尾提供一个综合实例,将本章知识综合运用,以促进理论与实践的结合。 首先,教程从C语言的历史、程序设计的初步知识开始,如字符集和词法记号。接着,介绍了基本数据类型,包括变量和常量的使用。在运算符和表达式部分,讲解了各种运算符(如算术、关系、逻辑、赋值等)的用法和优先级,以及数据类型转换和类型别名的概念。 面向对象设计思想是教程的另一重点,从程序设计语言的发展历程出发,对比面向过程和面向对象的思想,并通过卖报亭的例子来说明面向对象编程的实际应用。此外,教程还提供了C语言上机实践的指导,包括程序的实现过程和CBUILDER可视化编程环境的使用。 在后续章节,教程详细讲解了数据输入/输出、控制结构,如键盘输入、屏幕输出、选择结构(if-else和switch)、循环结构(while、do-while、for以及使用if-goto实现循环)以及跳转语句(break和continue)。通过水果收银机的编程实例,巩固了这些基础知识。 数组是程序设计中不可或缺的部分,教程涵盖了数组的基本概念、定义、赋值,特别是字符数组和字符串处理函数。此外,还有函数的定义、调用、参数传递(包括传值和引用调用)、嵌套调用、递归调用、默认形参值、内联函数和重载函数的介绍。通过二进制与十进制转换的实例,让读者实际操作函数的应用。 程序结构部分讲解了变量的作用域、生存期、存储类型,编译预处理(如文件包含、宏定义和条件编译),以及多文件结构。最后,指针作为C语言的关键特性,教程深入讨论了指针的概念、声明、初始化、引用,以及指针运算,如通过索引访问数组元素。 本教程适合C语言初学者,可作为高等院校电子信息类专业的教材,也可供非计算机专业学生自学。其内容精炼、语言通俗易懂,配合多样化的习题,有助于读者全面掌握C语言和面向对象编程的基础知识。
2008-06-18 上传
〖程序设计基础〗练习题1一、选择题(每题1分,共30分)下列各题A)、B)、C)、D)四个选项中,只有一个选项是正确的,请将正确选项的标记写在题干后的括号内。1.以下的选项中能正确表示Java语言中的一个整型常量的是( )。A) 12. B) -20 C) 1,000 D) 4 5 62.以下选项中,合法的赋值语句是( )。A) a = = 1; B) ++ i; C) a=a + 1= 5; D) y = int ( i );3.若所用变量都已正确定义,以下选项中,非法的表达式是( )。A) a != 4||b==1 B) 'a' % 3 C) 'a' = 1/2 D) 'A' + 324.若有定义int a = 2;则执行完语句a += a -= a * a; 后,a的值是( )。A) 0 B) 4 C) 8 D) -45.设有定义语句int a[]={66,88,99}; 则以下对此语句的叙述错误的是( )。A) 定义了一个名为a的一维数组 B) a数组有3个元素C) a数组的下标为1~3 D)数组中的每个元素是整型6.若a和b均是整型变量并已正确赋值,正确的switch语句是( )。A) switch(a+b); B) switch( a+b*3.0 ){ ...... } { ...... }C) switch a D) switch ( a%b ){ ...... } { ...... }7.下列语句序列执行后,x 的值是( )。int a=3, b=4, x=5;if( ++aA) 5 B) 3 C) 4 D) 68.下列语句序列执行后,k 的值是( )。int i=6, j=8, k=10, n=5, m=7;if( iA) 9 B) 10 C) 11 D) 129.下列语句序列执行后,r 的值是( )。char ch='8'; int r=10;switch( ch+1 ){ case '7': r=r+3;case '8': r=r+5;case '9': r=r+6; break;default: ;}A) 13 B) 15 C) 16 D) 1010.下列语句序列执行后,j 的值是( )。int j=0;for( int i=3; i>0; i-- ) j+=i;A) 3 B) 4 C) 5 D) 611.下列语句序列执行后,j 的值是( )。int j=9, i=6;while( i-- >3 ) --j;A) 5 B) 6 C) 7 D) 812.下列语句序列执行后,i的值是( )。int i=10;do { i-=2; } while( i>6 );A) 10 B) 8 C) 6 D) 413.为了区分重载多态中同名的不同方法,要求( )。A) 采用不同的形式参数列表 B) 返回值类型不同 C) 调用时用类名或对象名做前缀 D) 参数名不同14.定义主类的类头时可以使用的访问控制符是( )。A) private B) protected C) public D) private protected15.下列整型的最终属性 i 的定义中,正确的是( )。A) static final int i=100; B) final i;C) static int i; D) final float i=1.2f; 16.设 x,y 均为已定义的类名,下列声明对象x1的语句中正确的是( )。A) public x x1= new y( ); B) x x1=x( ); C) x x1=new x( ); D) int x x1;17.下列方法定义中,正确的是( )。A) int x( int a,b ) B) double x( int a,int b){ return (a-b); } { int w; w=a-b; }C) double x( a,b ) D) int x( int a,int b){ return b; } { return a-b; }18.能构成多分支的语句是( )。A) for 语句 B) while 语句 C) switch 语句 D) do -
2018-03-01 上传
Program design foundation-c programming experiment Description: Experiment 1 and 2 are both electronic lab reports. The following 8 experiments are paper lab reports. Experiment 1 computer basic operation The experiment purpose Familiar with computer, can be able to operate correctly, turn off operation. Be familiar with the keyboard, grasp the input of all characters on the keyboard, master the correct fingering, can carry on the middle, English switch. To understand the operating system concept, master the basic operation of Windows XP, and can use the "control panel" to set up some parameters. You will know the function of "recycle station", learn the basic operation of files and folders. It learns to search or find relevant files or folders on a computer, and master the use of wildcards. The experiment content, Familiar with the computer, familiar with the keyboard, the translation of input in English. The essay learns to enter with the correct fingering, knowing the input of all characters on the keyboard. The "control panel" is used to modify the system time, desktop background, and mouse properties. To create a new folder on the desktop, the folder is named after the student's own name + class +. Use a text or Word document to write a self-introduction that contains no less than 300 words and is named and saved in the above folder. The group copies the above folder to 22. Experiment 2 common software basic operation The experiment purpose Understanding Word function, the basic operation of Word, including the header/footer setting, the column, the page setting, adding the base line etc. 2 learn to file save and open, the interval of print preview, paragraphs, the first character position change, etc., can insert images, forms, art words in the Word, special symbols, etc. (3) understand the function of Excel, master the basic operation of the Excel, including cell properties of several kinds of filling form, the ce 发表评论 Program design foundation-c programming experiment Description: Experiment 1 and 2 are both electronic lab reports. The following 8 experiments are paper lab reports. Experiment 1 computer basic operation The experiment purpose Familiar with computer, can be able to operate correctly, turn off operation. Be familiar with the keyboard, grasp the input of all characters on the keyboard, master the correct fingering, can carry on the middle, English switch. To understand the operating system concept, master the basic operation of Windows XP, and can use the "control panel" to set up some parameters. You will know the function of "recycle station", learn the basic operation of files and folders. It learns to search or find relevant files or folders on a computer, and master the use of wildcards. The experiment content, Familiar with the computer, familiar with the keyboard, the translation of input in English. The essay learns to enter with the correct fingering, knowing the input of all characters on the keyboard. The "control panel" is used to modify the system time, desktop background, and mouse properties. To create a new folder on the desktop, the folder is named after the student's own name + class +. Use a text or Word document to write a self-introduction that contains no less than 300 words and is named and saved in the above folder. The group copies the above folder to 22. Experiment 2 common software basic operation The experiment purpose Understanding Word function, the basic operation of Word, including the header/footer setting, the column, the page setting, adding the base line etc. 2 learn to file save and open, the interval of print preview, paragraphs, the first character position change, etc., can insert images, forms, art words in the Word, special symbols, etc. (3) understand the function of Excel, master the basic operation of the Excel, including cell properties of several kinds of filling form。