0% found this document useful (0 votes)
49 views7 pages

Programming in C and Data Structures Luis Joyanes

1) The preface introduces the second edition of the book Programming in C, highlighting that C remains an ideal language for learning programming despite the passage of time. 2) The improvements made in this edition are described, such as the addition of new chapters, examples, and exercises, as well as the correction of errors. 3) Readers are invited to visit the book's website to access supplementary material such as appendices and solved problems.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
49 views7 pages

Programming in C and Data Structures Luis Joyanes

1) The preface introduces the second edition of the book Programming in C, highlighting that C remains an ideal language for learning programming despite the passage of time. 2) The improvements made in this edition are described, such as the addition of new chapters, examples, and exercises, as well as the correction of errors. 3) Readers are invited to visit the book's website to access supplementary material such as appendices and solved problems.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

PROLOGUE TO THE 2nd EDITION

INTRODUCTION
Welcome to Programming in C, 2nd edition. The preface of the first edition opened with the question-
Why a book about C at the beginning of the centuryXXIWe indeed wrote the book in the year 2000 and
was published in the year 2001. On this occasion, four years later, we have written the new edition in the
2004 and 2005, and it will be published in 2005. What has changed since then in the world of programming?
What? Really, a little and a lot. It remains the most used language for learning fundamentals and
programming techniques both in the university and in technological institutes and training centers
Professional training. C++ continues to reign in the learning of object-oriented programming and Java with
C# has become the premier language in the professional programming world, engineering-
software development, web engineering, telecommunications, and in general, the software industry.
C is an ideal language for learning computer programming. C is a very compact language.
since its syntax is simple and easy to learn for writing real applications. It is also a language
very powerful since it is widely used in programming at all levels, from device drivers
sensors and components of operating systems to large-scale applications. There are C compilers.
for any programming environment and operating systems, such as Windows, Unix, Linux, Mac,
etc., so that when you have learned C you will be able to program in any
text and current environment. You will also observe that C is an excellent basis for continuing your training in pro-
object-oriented programming with C++ and then migrate to Java or C# depending on the professional environment
to develop..
All university degrees in Sciences and Engineering, as well as vocational training studies
they require a basic course in algorithms and programming with a powerful and professional language but
it should be simple and easy to use. C is ideal for learning to program directly the algorithmic techniques.
or programming, or in parallel with subjects such as Introduction, Fundamentals, or Method.
Logic of Programming when using an algorithmic language or a structured programming language
C remains the most widely used and recommended universal language in university curricula.
and training centers around the world. Organizations such as ACM, IEEE, professional colleges, continue
recommending the need for in-depth knowledge of techniques and programming languages
structured with the objective of "accommodating" the student's training to the conception, design and construction
creation of algorithms and data structures. The deep knowledge of algorithms combined with reliable techniques-
Rigorous and efficient programming techniques prepare the student or self-taught individual for high performance.
in programming and to take on the challenges of object-oriented programming in an initial phase and the téc-
techniques and methods inherent to software engineering in another more advanced phase.
XXmmProgramming in C: Methodology, Algorithms, and Data Structures

A CLASSIC AND AT THE SAME TIME INNOVATIVE APPROACH TO LEARNING C


The experience gained from the several years of life of the first edition of Programming in C.
Methodology, algorithms, and data structures and their use in colleges and engineering schools, technical institutes.
Technological and vocational training centers have led us to consider the need to maintain the esti-
the first edition trying to add new features that would contribute to efficient learning
of programming in C, not only in the aesthetic aspect of the book but fundamentally in its structu-
the teacher. Thus, the most distinctive characteristics of this new edition are:
Each chapter begins with a list of the contents of each chapter, a brief introduction
to guide the reader on the topics to be addressed and a list of terms and keywords that are introduced
they will be used again as new or their use will be reiterated due to the importance they may have in learning:

• Frequent examples to aid learning.


• Theoretical and practical tips 'To remember'
• Programming tips
• Syntax of the grammatical rules of the C language
• Sample executions and C programs that allow the reader to get accustomed to the depu-
rationing and tuning of their programs
• Summary at the end of each chapter that facilitates the reader's assimilation of the most important concepts.
many of the same as a compendium and theoretical-practical reminder.
• Exercises and problems proposed to the reader in each chapter, with the fundamental objective of evaluating...
evaluate and measure their progress in learning C programming, both in design and construction
rather than the source program itself, by testing its efficiency by compiling and fine-tuning the program
with the compiler I used in my academic center during the programming practices in the laboratory
tutoring or in their study hours at home.

IMPORTANT DIFFERENCES WITH THE FIRST EDITION


PROGRAMMING IN C
The book has been fully revised and rewritten, retaining a large part of the original content.
It has been corrected and refined the theory, examples, and exercises, and new concepts have been included.
plows and practical exercises when their need has been seen from the teaching point of view and above all in
learning process.
Numerous readers, students, and colleagues from Spain and Latin America have suggested improvements to us.
they have pointed out typos or even mistakes that we had in the first edition, but above all they have pro-
let's include some topics not covered in the first edition or expand on some topics that are
Treaties are banned but not with sufficient extension like in the case of the important property of recursivity.
in the world of professional programming. We have tried to include all those numerous proposals and,
naturally, your advice. We hope to have interpreted all these considerations of our
readers and colleagues, to whom we want to thank for their trust in our work and their generosity from now on
criticism of the first edition. Their constructive critiques have constantly encouraged us in
the writing of this second edition.
The chapters that have been newly written are: 8, Recursion (in the first edition, they were included the
basic concepts in the chapter on functions);10, Sorting and Searching algorithms; 16, Orga-
Data organization in a file and 17 Abstract Data Types (ADT/Objects). Another noticeable change
The change in the organization of the book has occurred in the appendices. The incorporation of the preceding chapters-
the second edition required a considerable increase in the total number of pages of the book
something that for many reasons we did not want, which is why we have chosen not to include the appendices of
the 1st edition and include only some essentials in the printed edition and incorporate the appendices in
Prologue to the 2nd editionmmXXI

the official website of the book. However, McGraw-Hill's authorization allows the reader to
this second edition may include all the appendices from the first edition, as well as some new ones.
on the official Internet address of the book (http://www.mhe.es/joyanes) where you can see all
they and download to their computer those they wish and need for their learning and training
actual or future.
It will also be included on the official book page in addition to the appendices, teaching material com-
supplementary material from the authors with standards, rules, exercises and solved problems, class notes, bibliography
updated graphics, reference websites in programming, etc. that gradually aid learning
involvement of the reader in their professional career as a programmer or in their studies of computer science or
computational systems, or in the different engineering and scientific areas.

COMPANION BOOK OF THE SECOND EDITION


C PROGRAMMING
This second edition, like the first edition, can be studied or read in parallel with the work.
C Programming. Problem Book, by the authors of this work and the professors Andrés Castillo and
Lucas Sánchez, edited by McGraw-Hill, is a comprehensive collection of exercises and problems.
programming. Thinking about this new edition, the four previous authors have written a new book
C Problems in the Schaum collection by McGraw-Hill are predominantly theoretical-practical like all of them.
those belonging to this collection with the aim of helping readers to pass their exams and tests
lower practices and improve their learning, which although has a totally autonomous character, has been conceived-
I have written in a way that proposes and solves exercises and problems presented in the second edition with
a similar theme and content.
Either of the two books can help the reader interested in a complete supplementary training.
Practical and parallel to the content of this second edition. Likewise, on the official website of
In McGraw-Hill, the reader will find numerous proposed and solved exercises and problems.
programming in C(http://www.mhe.es/joyanes)

WHAT DO YOU NEED TO USE THIS BOOK?


C Programming, 2nd Edition, is designed to teach methods for writing useful programs.
as quick and easy as possible, learning both the syntax and functioning of the programming language at the same time.
Programming such as programming techniques and the fundamentals of building basic algorithms.
The content has been written with the possibility that the reader is:

• A novice in programming who wants to learn about programming and writing.


C programs from the beginning.
• A person with basic programming knowledge who has taken introductory courses in
algorithms or in classic languages like BASIC or PASCAL or C++ or Java.

The book is predominantly educational for formal teaching of computer programming, but
it does not presume any prior knowledge of programming, so it can also be used by
self-taught readers with or without training in computer science or computational sciences.
To use this book and get the most out of it, a computer with a...
C compiler, a library installed so that the examples from the book can be run, and an editor of
text to prepare your source code files. There are numerous C compilers on the market and
also numerous shareware versions (free of charge) available on the Internet. Ideally, it should be
give a compiler that is compatible with the standard version of C of the American National Standards Ins-
tute (ANSI) which is the version used in writing this book. Most of the current compile-
22mmProgramming in C: Methodology, algorithms, and data structure

available C++ libraries, either commercial or public domain, support C, so this may be
a highly recommended option.
You can use any text editor, such as Notepad or Vi, to create your files.
source grams, although it will be much better to use a specific editor for editing C code, like those that
they usually come with integrated development environments either for Windows or for Linux. However,
should not use a word processor, such as Microsoft Word, since word processors usually
text or commercial text treatment, embed or 'embed' format codes in the text that
they will not be understood by their compiler.
In any case, if you are taking a formal course, the best method to study this book is to follow
the advice of your teacher and professor both for your theoretical training and for your practical training. If
you are self-taught or study independently, the recommendation then will be to compile, execute-
and debug your programs, both those proposed in the book and those you design, at mid-
as I read the book, trying to understand the logic of the algorithm and the syntax of the language in each
exercise that I did.

HOW IS THE BOOK ORGANIZED?


All chapters follow a similar structure that respects the format of the first edition. Thus, each
The chapter begins with an excerpt from the contents, a brief introduction to the chapter, and a list of the
most important concepts and terms of the chapter. The theoretical and practical description is accompanied by
numerous examples and practical exercises with the fundamental objective that the reader/student goes
learning alongside those who follow and study its content. Below is a summary that includes a
Reminder of the most important theoretical and/or practical concepts of the chapter. Finally, it includes
a series of descriptions of beginner and intermediate level exercises, along with another list of statements
proposed problem sets, with the fundamental goal that the reader/student practices and sees the
progress made with the follow-up of the book as well as its theoretical-practical classes in their center
of teaching.
The book has been divided into three parts that aim to facilitate reading and study for the reader/student.
or the organization of the teacher or instructor for delivering their classes, so that they can organize
to tailor their classes in the way they deem best to achieve maximum effectiveness and the final objective
of a correct learning and mastery of programming in C at both beginner and advanced levels
means that enables him to start his profession as a 'C programmer' or move on to 'advanced level courses.'
Programming in C" or even systems programming. Part I "Methodology of the pro-
Programming is an introduction to computers, programming languages, and techniques.
typical programming tools regardless of the programming language used. The par-
The II 'Fundamentals of algorithms and programming in C' is an introductory course on programming.
computer programming using the C language; in general, this course will be similar to any course in
Introduction to Programming, Programming Methodology or Fundamentals of Programming
C as a programming tool; it will even not be difficult for you to adapt to any language of
algorithmic programming with simple syntax translation rules between languages. Part III
Data Structures is a mid-level course on a topic as important in programming as
it is the organization of data in data structures and information; this part should be studied
following the first part, although the order of the topics may be left to the discretion of the reader and/or
professor and teacher; in any form they constitute advanced topics in C and are an essential requirement.
for professional programming in C; in this part, the concept of Abstract Data Types is also studied.
Data (TAD, ADT in English, Abstract Data Type) and its implementation in C that will be the basis for the study.
the posterior side of object-oriented programming at a theoretical level and later practical with language-
just like C++, C# or Java.
Prologue to the 2nd editionmmXXIII

Chapter 1. Introduction to computers and programming languages. Explains and describes the
fundamental concepts of computing and programming languages. The knowledge-
Complete knowledge of the chapter's content is not an essential requirement for understanding.
to your learning of the remaining chapters although it is fundamental in your training of pro-
Programming. Under these circumstances, the reader/student can choose to study it all at once.
or adjust learning throughout their entire programming course. It is always counted
also with the professor and teacher who will be able to guide the student in their teaching progression. For
readers who have not taken any introductory course on computers or information
We recommend reading it before moving on to the next chapter and then rereading it.
at the time and in the manner that they themselves consider. This chapter has been updated total-
I lied about the first edition, and both the fundamental concepts and
traditional generics like the latest technological innovations that most affect the world
of programming.
Chapter 2. Methodology of programming and software development. The reader is introduced to the
Fundamental concepts of algorithms and their representation tools. Likewise, it is dis-
they write about the classical types of programming with special emphasis on structured programming
C language support. A brief introduction to the software lifecycle and to the
formal methods of program verification aims for the reader to mentally prepare themselves from the
beginning of their training in programming on the importance of these topics in the development
the software is modifiable and efficient.
Chapter 3. The C language. Basic elements.Introduces the structure and the main components.
speak of a C program. Teach the meanings of the fundamental elements of
all programs, such as data, constants, variables, and the basic input operations
from/exit.
Chapter 4. Operators and Expressions. It describes the use of arithmetic and relational operators.
logical operations for the manipulation of operations and expressions in C. Operations are also studied
special radars and type conversions, along with rules of priority and associativity
the operators in mathematical expressions and operations.
Chapter 5. Selection structures: statementsyfi Introduce the selection statements
basic and fundamental in any program. The use of compound statements is examined.
or blocks as well as the use of conditional operators and evaluation of logical expressions.
Chapter 6. Control structures: loops. The concept of loop or cycle is learned and the way to continue
to control the execution of a program through statementsfor, while, do-while. Tam-
The concept of nesting loops and empty loops is well explained; examples are provided.
useful tools for the efficient design of loops.
Chapter 7. Functions. Examines functions in C, an important part of programming. It is described
the concept of structured programming - a method of program design that emphasizes on
the top-down approach to problem solving through the decomposition of a pro-
big problem in lower-level problems that are implemented with functions.
Chapter 8. Recursion. Recursion is the property of a function or expression to call itself.
It is one of the most important techniques in algorithm construction. For this reason
a whole chapter is dedicated to the learning of recursive functions. In the first edition-
this concept was studied within the chapter on functions.
Chapter 9. Arrays (lists and tables). Explains a simple yet powerful method of data storage.
You learn how to group similar data in arrays or "arrays" (lists and tables) numerical
Chapter 10. Sorting and Searching Algorithms. It teaches the methods to sort lists and tables, thus
how to search for data in lists and tables. The simplest classical algorithms are studied
and efficient for both sorting and searching.
XXIVmmProgramming in C: Methodology, algorithms, and data structure

Chapter 11 Structures and joints. Basic concepts of structures, joints, and lists are described.
actions: declaration, definition, initiation, use, and size. The fundamental operations of
access to structures, arrays of structures and nested structures are also analyzed in this
chapter. In the chapter, it is practically shown how to use structures and unions to
meet the needs of the program; the differences between structures and unions are explained
yes, as well as the use of the reserved wordtypedef.
Chapter 12. Pointers. It presents one of the most powerful and efficient features of
C language, pointers. This chapter provides a detailed explanation of pointers.
pointer arrays, string pointers, pointer arithmetic, constant pointers, pointer-
ros as function arguments, pointers to functions and to structures. In a practical way-
tico learns how to use pointers to pointers and how they can be used with arrays
pointers to manipulate strings, which will be studied in depth in chapter 14.
Chapter 13. Dynamic memory allocation. It describes the dynamic management of memory and the functions
associated actions for those tasks:alloc(),free(),calloc()andrealloc().Pro-
they provide operational rules for those functions and rules for memory allocation.
Chapter 14. Strings. The concept of a string is described as well as the relationships between pointers.
arrays and strings in C. Basic concepts of string manipulation are introduced along with
basic operations such as length, concatenation, comparison, conversion, and search
of characters and strings. The most notable functions of the library are described.string.h
Chapter 15. File Input and Output. The concept of stream is studied and the different methods
two file opening methods, along with the concepts of binary files and functions for
random access. It shows practically how C uses streams, examining the flow-
predefined options and the practical mode of working with the screen, the printer, and the keyboard.
Chapter 16. Data organization in a file. The classical concepts of records and organization
Files are studied in the chapter. Two types of special files such as the seq.
indexed lists and with hash addressing for a specific study reason. Lastly
Sorting methods for files are analyzed both externally and by direct merging.
Chapter 17 Data types (ADT/Objects). Object-oriented programming is the most
important after the structured paradigm. The role of abstraction, modularity and
The abstract data types are analyzed in this chapter. The specification and ...
implementation of abstract data types in C as the first level of objects.
Chapter 18. Linked Lists. A linked list is a data structure that maintains a collection
of elements, but the number of them is not known in advance or varies in a wide range.
The linked list consists of elements that contain a value and a pointer. The chapter-
it describes the theoretical foundations, types of lists, and operations that can be performed on
the linked list.
Chapter 19. Stacks and queues. The most commonly used data structures from the point of view of abstraction
The implementation involves stacks and queues. Their structure, design, and manipulation of the algorithms.
the most basic are explained in the chapter.
Chapter 20 Trees. Non-linear and dynamic data structures are widely used in programs.
Trees are one of the most well-known structures in algorithms and programming.
since they are the foundation for advanced programming techniques.
Prologue to the 2nd editionmm25

APPENDICES
Compilation of C programs on Windows
Bibliography and programming resources

APPENDICES AVAILABLE ON THE WEB


W1 ASCII Code
Reserved Words C/C++
W3Language ANSI C. Reference Guide
W4 ANSI/ISO C++ Syntax Guide
W5 ANSI C Function Library
W6 Resources of C (books, magazines, web)
W7C versus C++
W8Operator precedence C/C++
W9Algorithmic language UPSAM 2.0

You might also like