Teach Yourself C language / PDF

Teach Yourself C language  / PDF








Sample of the pdf document 







What Is C?

C is a programming language. The C language was first developed in 1972 by Dennis Ritchie at AT&T Bell Labs.

Ritchie called his newly developed language C simply because there was a B programming language already. (As a matter of fact, the B language led to the development of C.)

C is a high-level programming language. In fact, C is one of the most popular general-purpose programming
languages.

In the computer world, the further a programming language is from the computer architecture, the higher the
language's level. You can imagine that the lowest-level languages are machine languages that computers understand directly.

 The high-level programming languages, on the other hand, are closer to our human languages.


High-level programming languages, including C, have the following advantages:


  •  Readability: Programs are easy to read.
  •  Maintainability: Programs are easy to maintain.
  •  Portability: Programs are easy to port across different computer platforms.

The C language's readability and maintainability benefit directly from its relative closeness to human languages, especially English.

Each high-level language needs a compiler or an interpreter to translate instructions written in the high-level
programming language into a machine language that a computer can understand and execute. Different machines may
need different compilers or interpreters for the same programming language. For instance, I use Microsoft's C compiler to compile the C programs in this book for my personal computer (PC). If I need to run the C programs on a UNIX-based workstation, I have to use another type of C compiler to compile these programs. Therefore, the portability of programs written in C is realized by re-compiling the programs with different compilers for different machines. (See Figure 1.2.)


The Hardware and Software I Use for C Programming

I have a Pentium 100MHz PC with 32MB memory and with a 2.5GB hard drive. (32MB memory may be more than enough to run the C programs from this book, but I need a lot of memory space for Windows programming.) I have both Windows 95 and Windows NT on my machine.


In this book, all C programs are developed with Microsoft Visual C++ version 1.5. (The latest version of Visual C++ is 5.0.) The reasons I chose Visual C++ 1.5 are simple: All C programs in this book are written in ANSI C and can be compiled into DOS-based applications; Visual C++ 1.5 has a good C compiler that supports the ANSI standard, as
well as a simple but friendly enough IDE. Figure 1.3 shows an example of the IDE from Visual C++ 1.5. (The later version of Visual C++ has a fancy IDE with more features added. However, many of those features are not needed for running the C programs in this book.)
I set up my development environment in such a way that all C programs in this book can be compiled and made into DOS applications. Also, I test and run the applications made from the C programs at a DOS prompt provided by
Windows 95.
Summary
In this first lesson you've learned the following:
 C is a general-purpose programming language.
 C is a high-level language that has the advantages of readability, maintainability, and portability.
TIP
You can learn more about Borland C++ or Visual C++ from books such as Teach Yourself Borland C++
5 in 21 Days (from Sams Publishing/Borland Press) and Teach Yourself Visual C++ 5 in 21 Days (also
from Sams Publishing).
 C is a very efficient language that allows you to get control of computer hardware and peripherals.
 C is a small language that you can learn easily in a relatively short time.
 Programs written in C can be reused.
 Programs written in C must be compiled and translated into machine-readable code before the computer can
execute them.
 C provides many programming languages, such as Perl, C++, and Java, with basic concepts and useful features.
 The ANSI standard for C is the standard supported by all C compiler vendors to guarantee the portability of C.
 You can use any C compilers that support the ANSI standard and compile all C programs in this book.
In the next lesson you'll learn to write your first C program.
Q&A
Q What is the lowest-level language in the computer world?
A The computer's machine language is the lowest because the machine language, made up of 0s and 1s,
is the only language that the computer can understand directly.
Q What are the advantages of high-level programming languages?
A Readability, maintainability, and portability are the main advantages of high-level programming
languages.
Q What is C, anyway?
A C is a general-purpose programming language. It's a high-level language that has advantages such as
readability, maintainability, and portability. Also, C allows you to get down to the hardware to increase
the performance speed if needed. A C compiler is needed to translate programs written in C into
machine-understandable code. The portability of C is realized by recompiling the C programs with
different C compilers specified for different types of computers.
Q Can I learn C in a short time?
A Yes. C is a small programming language. There are not many C keywords or commands to remember.
Also, it's very easy to read or write in C because C is a high-level programming language that is close to
human languages, especially English. You can learn C in a relatively short time.
Workshop
To help solidify your understanding of this hour's lesson, you are encouraged to answer the quiz questions provided
in the Workshop before you move to the next lesson. The answers and hints to the questions are given in Appendix E,
"Answers to Quiz Questions and Exercises."






 Click here for  Download PDF / FREE

Teach Yourself C language  / PDF





1 commentaire: