Sie sind auf Seite 1von 5

Programming in C

INTRODUCTION
1. C is a programming language developed by at ATs & Ts Bell Laboratories of USA in 1972. It was designed & written by a man named Dennis Ritchie. 2. In the late seventies C Began to replace the more familiar language of that time like PL/I, ALGOL, etc. 3. No one pushed C. It wasnt made the official Bell Lab Language. Thus, without any advertisement Cs reputation spread and its pool of users grew. 4. Possibly why C seems so popular is because it is reliable, simple & easy to use. Moreover, in an industries where newer languages, tools & technologies emerge & vanish day in & day out, a language that has survived for more than 3 decades has to be really good. 5. Their objectives were to develop a language which will have the version (features) of high level programming language. C mainly independent with the efficiency of an assembly language.

FEATURES OF C LANGUAGE
1. It was developed as compiled language. C uses complier as it is translator. So that C language program could be easily run to other computers equipped with C compiler. 2. It supports pointers with pointer operation. These feature allow that programmer to directly access the memory address where variable are stored & to perform. Bit level manipulation of data stored in memory or processor register. 3. It support user define data types for greater flexibility in programming. 4. It is small & consist language providing only essential features so that C language program can be translated by language translator into a machine language code. 5. At time one is required to very closely interact with the hardware device since C provides several language elements that make this interaction flexible without compromising the performance. It is preferred choice of program.

Programming in C

GETTING START WITH C


Communicating with the computer involves speaking the language the computer understands, which immediately rules out English as the language of communication with computer. However, there is a close analogy between learning English and learning C language.

STEPS IN LEARNING ENGLISH LANGUAGE Alphabets Words Sentences Paragraph

STEPS IN LEARNING C

Aplabets Digits Speacial Symbol

Constants Variables Keywords


Instructions Porgrams

Learning C language is easier. But before writing C language program, we must first know what Alphabets, numbers & special symbols are used in C language, then how using them constants, variables & keywords are constructed & finally how are these combined to form an instruction. And finally group of instructions would be combined later on to form a program.

THE C CHARACTER SET


A character denotes any alphabet, digit or special symbol used to represent information Following table shows the valid alphabets, number & special symbols allowed in C.

Alphabets Digits Special Symbol

A, B, .........Y, Z a, b, ..........y, z ~!@#%^&*()_-+=|, -* +:; < >,.?/

Programming in C

CONSTANTS
A constant is an entity that doesnt change. TYPES OF CONSTANT C constants can be divided into two major categories. 1. Primary Constants 2. Secondary Constants These Constants are further categories as showing in figure below.

C Constants

Primary Constant

Secondary Constant Arrary Pointer Structure Union Enum, Etc..

Integer Constant Real Constant Charecter Constant

RULES FOR CONSTRUCTING INTEGER CONSTANTS a) b) c) d) e) f) An integer constant must have at least one digit It must not have a decimal point. It can be either positive or negative. If no sign precedes an integer constant it is assumed to be positive. No commas or Blank are allowed within an integer constant. The Allowable range for integer constant is -32768 to +32767.

E.g. 426, +788, -6020, -7642 RULES FOR CONSTRUCTING REAL CONSTANTS Real constants are often called floating point constants. The real constants could be written in two forms Fraction form & Exponential form. Following rules be observed while constructing real constants expressed in fraction forms. a) b) c) d) e) An real constant must have at least one digit It must have a decimal point. It can be either positive or negative. Default sign be positive. No commas or Blank are allowed within an integer constant.

E.g. +3.25, 465.01, -32.65

Programming in C The exponential form representation of real constant is usually used if the value of the constant is either too small or too large. In exponential form of representation the real constant represented in to two parts. The part appearing before e is called mantissa, where as the part following e is called exponent. RULES FOR CREATING REAL CONSTANT IN EXPONENTIAL FORM. a) b) c) d) The mantissa part and the exponential part should be separated by the letter e. The mantissa part may have a positive or negative sign. Default sign of mantissa part is positive. The exponent must have at least one digit, which must be a positive or negative integer. Default sign is positive e) Range of real constants expressed in exponential form is -3.4e38 to 3.4e38. Eg. +3.2e-5, 4.1e8, -0.2e+3 RULES FOR CONSTRUCTING CHARACTER CONSTANTS A character constant is a single alphabet, a single digit or a single special symbol enclosed within single inverted commas. Both the inverted commas should point to the left. For eg. A is a valid character constant. A is not valid character constant. The maximum length of a character constant can be one character.

Das könnte Ihnen auch gefallen