CP264 Lesson 1.1 - Introduction to C PDF

Document Details

HaleNeodymium

Uploaded by HaleNeodymium

Wilfrid Laurier University

Tags

C programming data structures computer science algorithms

Summary

This document introduces the C programming language, discussing its background, characteristics, and applications, especially in the context of algorithm design and data structures. The lesson emphasizes the importance of C for fundamental understanding within computer science.

Full Transcript

2/11/25, 6:52 PM CP264 Lesson 1.1 Lesson 1 Introduction to C 1.1 INTRODUCTION We are not teaching C programming language in this course. We us...

2/11/25, 6:52 PM CP264 Lesson 1.1 Lesson 1 Introduction to C 1.1 INTRODUCTION We are not teaching C programming language in this course. We use C to teach data structures. Students taking this course may already learned C. If C is new to you, you are encouraged to take a tutorial on C. But don’t worry if you never touched C before. We will introduce features of C from the perspective of studying data structures. As time goes on, you will learn C and eventually be familiar with C programming after completing the course. First of all, why do we use the C programming language in this Data Structures II course? C is the de facto standard of programming languages. It has been used to implement operating systems such as Unix, Linux, Windows OS, and macOS. It is the primary programming language for computer science and computer engineering. C is simple yet powerful enough to perform low-level operations. Using C for data structures makes it possible to: 1. Understand fundamentally how data structures work at the memory level. 2. Design, implement, and use data structures for efficient data representation, storage, access, and processing. 3. Design application-specific data structures to improve the performance of algorithms. Learning and doing data structures using C will bridge the knowledge gap between computer hardware (processors,Learning and working with data structures using C will bridge the knowledge gap between computer hardware (processors, memory, etc.) and software by illustrating how software operates on hardware. Mastering data structures in C will lay a solid foundation for advanced computer science courses, including: Algorithm Design and Analysis: Data structures are used in algorithms to represent and access data. System Programming: The C programming language and many data structures are used extensively. Operating Systems: The C programming language and fundamental data structures are critical. Computer Graphics: C++, the OpenGL library, and customized high- performance data structures are utilized. https://mylearningspace.wlu.ca/content/enforced/568518-1318.202501/content/lessons/L01/L01_01.html 1/5 2/11/25, 6:52 PM CP264 Lesson 1.1 Introduction to Compiling: Numerous auxiliary data structures are employed in compiler programs. 1.1.1 Background of C Origin C is a general-purpose programming language initially created and developed by Dennis Ritchie (supplementary link) between 1969 and 1973 at AT&T Bell Labs. Dennis Ritchie created the C programming language to rewrite and export the UNIX operating system to different platforms. UNIX was originally designed and written by Ken Thompson (supplementary link) in assembly language for DEC PDP-7 computers. Since assembly programs are hard to debug and enhance, Thompson designed a small programming language named “B” for rewriting UNIX. The B programming language was based on BCPL (supplementary link), a systems programming language developed in the mid- 1960s. Dennis Ritchie joined the UNIX project and developed an extended version of B with new features to meet the needs of UNIX development. He renamed it “C” as the successor to “B”. UNIX was rewritten in C, and was exported to other computer platforms by using platform-dependent C compilers. Further more, application programs written in C could be compiled by the compilers and run on different computers. This means that C programs are portable. This portability makes C a general-purpose programming language for applications. Standardization The first book on C, The C Programming Language reference 2, was written by Brian Kernighan (supplementary link) and Dennis Ritchie, and published in 1978. It served as a standard reference for learning and using C. It was a must-read book for anyone learning C, and is termed K&R by C programmers. In the 1980s, C continued to evolve into a general-purpose programming language with new features added and some old features removed. The need for a standard description for up-to-date features became critical for the healthy growth of C. Without a standard, different C compilers would have different sets of features, making C programs compilable by one compiler potentially non-compilable by another, thereby reducing their portability. The development of C standard began in 1983. The first C standard was completed in 1988, approved by American National Standards Institute (ANSI) in 1989, and further approved by International Organization for Standardization (ISO) in 1990. This first C standard is known as ANSI C, C89, or C90, while the original C is https://mylearningspace.wlu.ca/content/enforced/568518-1318.202501/content/lessons/L01/L01_01.html 2/5 2/11/25, 6:52 PM CP264 Lesson 1.1 referred to as K&R C. Further evolution of C and its standard in the 1990s led to a revised C standard, approved by ISO in 1999, known as C99. C18 was approved by ISO in 2018. For more information about C standards, refer to the ISO site (supplementary link). In this course, we will use the C89 for C code examples, and GNU C compiler GCC (supplementary link) for testing. For details of C89, refer to the C89 draft. 1.1.2 Characteristics of C Several characteristics make C the de facto standard programming language. 1. C is a high level programming language 2. C is a low level language 3. C is a portable (or cross-platform) language 4. C is a small language 5. C is extensible 6. C is a stable 1.1.3 Applications of C The standardization and characteristics of C make it the primary programming language in computer software development. C compilers are available for almost all computer architectures and operating systems. C is utilized in numerous applications and tools. Here are some examples: 1. C is used for operating systems and high performance computing. 2. C is used for interpreters of other programming languages. 3. C has influenced other programming languages. 1.1.4 C for data structures The characteristics of C make it a primary language for implementing data structures. Its features, including low-level memory operations, enable the design https://mylearningspace.wlu.ca/content/enforced/568518-1318.202501/content/lessons/L01/L01_01.html 3/5 2/11/25, 6:52 PM CP264 Lesson 1.1 and efficient implementation of data structures. C allows for accessing and operating on data components within data structures efficiently. C is widely used as a tool for teaching data structures. Learning data structures with C enhances fundamental understanding of how they operate. Understanding data structures at the memory level enables efficient design and implementation for algorithms and applications. In Data Structures II, we use C to gain a deep understanding of how data structures function and to learn how to utilize them for high-performance algorithm design and implementation. Proficiency in C and data structures establishes a solid foundation for advanced computer science courses and careers in software development. Numerous books and online resources are available for learning the C programming language. For a fundamental understanding, reference 2 is an excellent starting point. For more comprehensive learning, consider reference 3, which provides in-depth coverage of C programming. Notation convention We primarily use standard notations in content descriptions, with some exceptions. For instance, we use * to denote the multiplication operator instead of the standard mathematical symbols or ×. In theoretical proofs, ≤ represents “less than or equal to,” whereas

Use Quizgecko on...
Browser
Browser