Example: confidence

C Programming Tutorial - Mark Burgess

---titleSpecial Assignment Operators++and--C Programming Tutorial4th Edition (K&R version)Mark BurgessFaculty of Engineering, Oslo CollegeCopyrightc 1987,1999 Mark BurgessPermission is granted to make and distribute verbatim copies of this manualprovided the copyright notice and this permission notice are preserved on program is limited by the language which is used to write it. C is aprogrammer s language. Unlike BASIC or Pascal, C was not written as ateaching aid, but as an implementation language. C is a computer languageand a Programming tool which has grown popular because programmers likeit! It is a tricky language but a masterful one.

C Programming Tutorial 4th Edition ... C is a computer language and a programming tool which has grown popular because ... C tries to make the best of a computer by ...

Tags:

  Programming, Tutorials, C programming tutorial

Information

Domain:

Source:

Link to this page:

Please notify us if you found a problem with this document:

Other abuse

Transcription of C Programming Tutorial - Mark Burgess

1 ---titleSpecial Assignment Operators++and--C Programming Tutorial4th Edition (K&R version)Mark BurgessFaculty of Engineering, Oslo CollegeCopyrightc 1987,1999 Mark BurgessPermission is granted to make and distribute verbatim copies of this manualprovided the copyright notice and this permission notice are preserved on program is limited by the language which is used to write it. C is aprogrammer s language. Unlike BASIC or Pascal, C was not written as ateaching aid, but as an implementation language. C is a computer languageand a Programming tool which has grown popular because programmers likeit! It is a tricky language but a masterful one.

2 Sceptics havesaid that it isa language in which everything which can go wrong does go wrong. True, itdoes not do much hand holding, but also it does not hold anything back. Ifyou have come to C in the hope of finding a powerful language forwritingeveryday computer programs, then you will not be disappointed. C is ideallysuited to modern computers and modern book is a Tutorial . Its aim is to teach C to a beginner, butwithenough of the details so as not be outgrown as the years go by. It presumesthat you have some previous aquaintance with Programming you need toknow what a variable is and what a function is but you do not need muchexperience.

3 It is not essential to follow the order of the chapters rigorously,but if you are a beginner to C it is recommended. When it comes down toit, most languages have basically the same kinds of features: variables, waysof making loops, ways of making decisions, ways of accessingfiles etc. If youwant to plan your assault on C, think about what you already know aboutprogramming and what you expect to look for in C. You will mostlikely findall of those things and more, as you work though the examples programs range from quick one-function programs, whichdo no more than illustrate the sole use of one simple feature,to completeapplication examples occupying several pages.

4 In places these examples makeuse of features before they have properly been explained. These programsserve as a taster of what is to Burgess . 1987, 1999 This book was first written in 1987; this new edition was updated andrewritten in 1999. The book was originally published by DabsPress. Sincethe book has gone out of print, David Atherton of Dabs and I agreed torelease the manuscript, as per the original contract. This new edition iswritten in Texinfo, which is a documentation system that uses a single sourcefile to produce both on-line information and printed can readthis Tutorial online, using either the Emacs Info reader, the standalone Inforeader, or a World Wide Web browser, or you can read this same text as atypeset, printed Levels and Low Levels11 IntroductionWhat is C?

5 What is it for? Why is it special? High Levels and Low LevelsAny kind of object that is sufficiently complicated can be thought of ashaving levels of detail; the amount of detail we see depends upon how closelywe scrutinize it. A computer falls definitely into the category of complexobjects and it can be thought of as working at many different levels. Thetermslow levelandhigh levelare often used to describe these onion-layersof complexity in computers. Low level is perhaps the easiestto understand:it describes a level of detail which is buried down amongst the working partsof the machine: the low level is the level at which the computer seems mostprimitive and machine-like.

6 A higher level describes the same object, butwith the detail left out. Imagine stepping back from the complexity of themachine level pieces and grouping together parts which worktogether, thencovering up all the details. (For instance, in a car, a group of nuts, bolts,pistons can be grouped together to make up a new basic object:an engine.)At a high level a computer becomes a group of black boxes whichcan thenbe thought of as the basic components of the is called a high level, compiler language. The aim of any high levelcomputer language is to provide an easy and natural way of giving a pro-gramme of instructions to a computer (a computer program).

7 The languageof the raw computer is a stream of numbers called machine code. As youmight expect, the action which results from a single machinecode instruc-tion is very primitive and many thousands of them are required to make aprogram which does anything substantial. It is therefore the job of a highlevel language to provide a new set of black box instructions, which can begiven to the computer without us needing to see what happens inside them and it is the job of a compiler to fill in the details of these"black boxes"2 Chapter 1: Introductionso that the final product is a sequence of instructions in the language of is one of a large number of high level languages which can be used forgeneral purpose Programming , that is, anything from writing small programsfor personal amusement to writing complex applications.

8 Itis unusual inseveral ways. Before C, high level languages were criticized by machinecode programmers because they shielded the user from the working detailsof the computer, with their black box approach, to such an extent thatthe languages become inflexible: in other words, they did notnot allowprogrammers to use all the facilities which the machine has to offer. C, onthe other hand, was designed to give access to any level of themachine downHigh Levels and Low Levels3to raw machine code and because of this it is perhaps the most flexible ofall high level , Programming books often ignore an importantrole of highlevel languages: high level programs are not only a way to express instruc-tions to the computer, they are also a means of communicationamong hu-man beings.

9 They are not merely monologues to the machine, they are away to express ideas and a way to solve problems. The C language hasbeen equipped with features that allow programs to be organized in an easyand logical way. This is vitally important for writing lengthy programsbecause complex problems are only manageable with a clear organizationand program structure. C allows meaningful variable names and meaningfulfunction names to be used in programs without any loss of efficiency and itgives a complete freedom of style; it has a set of very flexibleloop construc-4 Chapter 1: Introductiontions (for,while,do) and neat ways of making decisions.

10 These provide anexcellent basis for controlling the flow of unusual feature of C is the way it can express ideas richness of a language shapes what it can talk about. C gives us theapparatus to build neat and compact programs. This sounds, first of all,either like a great bonus or something a bit suspect. Its conciseness canbe a mixed blessing: the aim is to try to seek a balance betweenthe oftenconflicting interests of readability of programs and their conciseness. BecauseThe Compiler5this side of Programming is so often presumed to be understood, we shalltry to develop a style which finds the right allows things which are disallowed in other languages: this is no defect,but a very powerful freedom which, when used with caution, opens up possi-bilities enormously.


Related search queries