![C](https://img.perlego.com/book-covers/2193051/9781351796439_300_450.webp)
eBook - ePub
C
From Theory to Practice, Second Edition
George S. Tselikis, Nikolaos D. Tselikas
This is a test
- 696 pages
- English
- ePUB (mobile friendly)
- Available on iOS & Android
eBook - ePub
C
From Theory to Practice, Second Edition
George S. Tselikis, Nikolaos D. Tselikas
Book details
Book preview
Table of contents
Citations
About This Book
This easy-to-use, classroom-tested textbook covers the C programming language for computer science and IT students. Designed for a compulsory fundamental course, it presents the theory and principles of C. More than 500 exercises and examples of progressive difficulty aid students in understanding all the aspects and peculiarities of the C language. The exercises test students on various levels of programming and the examples enhance their concrete understanding of programming know-how. Instructor's manual and PowerPoint slides are available upon qualifying course adoption
Frequently asked questions
How do I cancel my subscription?
Can/how do I download books?
At the moment all of our mobile-responsive ePub books are available to download via the app. Most of our PDFs are also available to download and we're working on making the final remaining ones downloadable now. Learn more here.
What is the difference between the pricing plans?
Both plans give you full access to the library and all of Perlegoās features. The only differences are the price and subscription period: With the annual plan youāll save around 30% compared to 12 months on the monthly plan.
What is Perlego?
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, weāve got you covered! Learn more here.
Do you support text-to-speech?
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Is C an online PDF/ePUB?
Yes, you can access C by George S. Tselikis, Nikolaos D. Tselikas in PDF and/or ePUB format, as well as other popular books in Computer Science & Information Technology. We have over one million books available in our catalogue for you to explore.
Information
1 Introduction to C
Before getting into the details of C language, this chapter presents, in brief, its history, evolution, strengths, and weaknesses. Then, weāll discuss some basic concepts that weāll need in order to write our first program.
History of C
The C language was developed at Bell Labs in the early 1970s by Dennis Richie and others. At that time, the Unix operating system, also developed at Bell Labs, was written in assembly language. Programs written in assembly are usually hard to debug, maintain, and enhance, and Unix was no exception. Richie decided to rewrite Unix code in another language that would make the execution of these tasks easier. He named the language C because it was the evolution of an earlier language written by Ken Thompson, called B. The C language continued to evolve during the 1970s, and since then, it has been used by thousands of programmers for a wide variety of applications.
The ANSI Standard
The rapid expansion of the C language and its increased popularity led many companies to develop their own C compilers. Due to the absence of an official standard, their development relied on the bible of C programmers, the legendary K&R book, written by Brian Kernighan and Dennis Ritchie in 1978.
However, the K&R book was not written in the precise way that a standard requires. Features that were not clearly described could be implemented in different ways. As a result, the same program could be compiled with one C compiler and not with another. In parallel, the C language continued to evolve with the addition of new features and the replacement or obsolescence of existing ones.
The need for the standardization of C language became apparent. In 1983, the American National Standard Institute (ANSI) began the development of the C standard that was completed and formally approved, in 1989, as ANSI C or Standard C. In 1990, the ANSI C standard was adopted by the International Standards Organization (ISO) as ISO/IEC 9899:1990. This standard describes precisely the features, characteristics, and properties of the C language, and every C compiler must support it.
The addition of some new features to the ANSI standard during the late 1990s led to a new standard called C99. C99 was further enriched with new features, leading to the publication of the C11 standard. This book describes the C language based on the ANSI/ISO C standard.
Advantages of C
Despite the emergence of many programming languages, C still remains competitive and popular in the programming world for several reasons, such as the following:
- It is a flexible language, which can be used for the development of different kinds of applications, from embedded systems and operating systems to industrial applications. For example, weāve used C in the area of communication networks for the development of network protocols and the support of network services.
- A C program is executed very quickly.
- It is a small language. Its vocabulary consists of a few words with special meanings.
- It is portable, meaning that a C program may run under different operating systems.
- It supports structural programming, meaning that a C program may contain functions to perform several tasks.
- It is a language very close to the hardware and it can be used for systems programming.
- Every C compiler comes with a set of ready-to-use functions, called C standard library. The use of these library functions saves considerable programming effort.
- Thanks to the popularity of the C language, there are many C compilers available; some of them free of charge.
- Learning C will help you to learn other languages. For example, getting familiar with C is the first step toward object-oriented programming. Most of the C features are supported in several object-oriented languages, like C++, Java, and C#.
Disadvantages of C
- Because the C language does not impose many restrictions on the use of its features, it is an error-prone language. When writing a C program, be cautious because you may insert bugs that wonāt be detected by the compiler.
- C supports only single-thread flow; it does not support multithread programming, parallel operation, and synchronization.
- Although C is a small language, it is not an āeasy-to-useā language. C code can be very hard to understand even if it consists of a small number of lines. After reading this book, check out the International Obfuscated C Code Contest (http://www.ioccc.org) to get a feeling.
- C is not an object-oriented language; therefore, it does not support object-oriented features.
C Program Life Cycle
The life cycle of a C program involves several steps: write the code, compile the code, link the object code produced by the compiler with any code needed to produce the executable file, and run the program. Usually, a C compiler provides an integrated development environment (IDE) that allows us to perform this set of operations without leaving the environment.
Writing a C Program
To write a C program, we can use any available text editor. An editor is often integrated with the compiler. The source code must be saved in a file with extension .c. When the size of the code is very large, it is a common practice to divide the code into several files, in order to facilitate tasks like testing and maintenance. In such cases, each file is compiled separately.
Our First C Program
Our first program will be a ārockā version of the program that most programmers begin with. Instead of the classical āHello worldā message, our first program displays on the screen the classical song of Ramones, Hey Ho, Letās Go. Play it loud, and letās go ā¦
#include <stdio.h> int main(void) { printf("Hey Ho, Let's Go\n"); return 0; }
The following sections explain the significance of each program line.
The #include
Directive
The
#include
directive instructs the compiler to include the contents of the stdio.h
file into the program before it is compiled. Regarding syntax, directives always begin with a #
character and do not end with a semicolon ;
or some other special marker.The
stdio.h
file and other files contain information about the standard library functions. The typical extension is .h
and they are called header files. These files are supplied with the compiler. For example, as shown in Appendix C, the stdio.h
(standard input output) file contains declarations of data input and output functions, and because of that, it is almost always included in a program. An included file may also contain #include
directives and include other files. In general, when you are using a standard library function, you must include the header file that contains its declaration. The order of their inclusion does not matter. When you get familiar with the C language, you may edit your own header files and include them in your programs.When the program is compiled, the compiler searches for the included files. The searching rules depe...
Table of contents
- Cover
- Half Title Page
- Title Page
- Copyright Page
- Dedication
- Contents
- Preface
- Acknowledgments
- About the Authors
- Chapter 1 Introduction to C
- Chapter 2 Data Types, Variables, and Data Output
- Chapter 3 Getting Input with scanf()
- Chapter 4 Operators
- Chapter 5 Program Control
- Chapter 6 Loops
- Chapter 7 Arrays
- Chapter 8 Pointers
- Chapter 9 Characters
- Chapter 10 Strings
- Chapter 11 Functions
- Chapter 12 Searching and Sorting Arrays
- Chapter 13 Structures and Unions
- Chapter 14 Memory Management and Data Structures
- Chapter 15 Files
- Chapter 16 The Preprocessor
- Chapter 17 Building Large Programs
- Chapter 18 Introduction to C++
- Chapter 19 Introduction to Java
- Chapter 20 Review Exercises
- Appendix 1 Precedence Table
- Appendix 2 ASCII Table
- Appendix 3 Library Functions
- Appendix 4 Hexadecimal System
- Index
Citation styles for C
APA 6 Citation
Tselikis, G., & Tselikas, N. (2017). C (2nd ed.). CRC Press. Retrieved from https://www.perlego.com/book/2193051/c-from-theory-to-practice-second-edition-pdf (Original work published 2017)
Chicago Citation
Tselikis, George, and Nikolaos Tselikas. (2017) 2017. C. 2nd ed. CRC Press. https://www.perlego.com/book/2193051/c-from-theory-to-practice-second-edition-pdf.
Harvard Citation
Tselikis, G. and Tselikas, N. (2017) C. 2nd edn. CRC Press. Available at: https://www.perlego.com/book/2193051/c-from-theory-to-practice-second-edition-pdf (Accessed: 15 October 2022).
MLA 7 Citation
Tselikis, George, and Nikolaos Tselikas. C. 2nd ed. CRC Press, 2017. Web. 15 Oct. 2022.