30-06-2012, 12:30 PM
details about c
c book.docx (Size: 80.37 KB / Downloads: 29)
Introduction
Let us begin with a quick introduction in C. Our aim is to show the essential elements of the language in real programs, but without getting bogged down in details, rules, and exceptions. At this point, we are not trying to be complete or even precise (save that the examples are meant to be correct).
We want to get you as quickly as possible to the point where you can write useful programs, and to do that we have to concentrate on the basics: variables and constants, arithmetic, control flow, functions, and the rudiments of input and output. We are intentionally leaving out of this chapter features of C that are important for writing bigger programs. These include pointers, structures, most of C's rich set of operators, several control- flow statements, and the standard library.
This approach and its drawbacks. Most notable is that the complete story on any particular feature is not found here, and the tutorial, by being brief, may also be misleading. And because the examples do not use the full power of C, they are not as concise and elegant as they might be. We have tried to minimize these effects, but be warned. Another drawback is that later chapters will necessarily repeat some of this chapter. We hope that the repetition will help you more than it annoys.
In any case, experienced programmers should be able to extrapolate from the material in this chapter to their own programming needs. Beginners should supplement it by writing small, similar programs of their own. Both groups can use it as a framework on which to hang the more detailed descriptions that begin in Chapter 2.
Getting Started
The only way to learn a new programming language is by writing programs in it. The first program to write is the same for all languages: Print the words
Hello, world
This is a big hurdle; to leap over it you have to be able to create the program text somewhere, compile it successfully, load it, run it, and find out where your output went. With these Mechanical details mastered, everything else is comparatively easy.
Real Constant
• It must have at least one digit.
• It must have a decimal point which may be positive or negative.
• Use of blank space and comma is not allowed between real constants.
• Example:
Integer Constant
• It must have at least one digit.
• It should not contain a decimal place.
• It can be positive or negative.
• Use of blank space and comma is not allowed between real constants.
Character Constant
• It is a single alphabet or a digit or a special symbol enclosed in a single quote.
• Maximum length of a character constant is 1.
• Example:
String Constant
• It is collection of characters enclosed in double quotes.
• It may contain letters, digits, special characters and blank space.
"LIVESKY Embedded solutions"
DATA TYPES
A programming language is proposed to help programmer to process certain kinds of data and to provide useful output. The task of data processing is accomplished by executing series of commands called program. A program usually contains different types of data types (integer, float, character etc.) to store the values being used in the program along with some library function and user defined function (UDF) to process that stored data. C language is rich of data types and library function. A C programmer has to employ proper data type as per his/her requirement.