Você está na página 1de 13

CONSTANTS,KEYWORDS,VARIABLES & LITERALS

PRESENTED BY :

is a programming language developed at AT& Ts BELL laboratories of USA in 1972 It was designed & written by a man named DENNIS RITCHIE In the late 70s C began to replace the more familiar languages of that time like PL/I,ALGOL

A constant is an entity that doesnt change , whereas, a variable is an entity that may change Types of constants: a)Primary constants b)secondary constants

Keywords are the words whose meaning has already been explained to the C compiler (or in a broad sense to the computer). The keywords cannot be used as variable names because if we do so, we are trying to assign a new meaning to the keyword. which is not allowed by the computer. some C compilers allowed by the computer. Some C compilers allow you to costruct variable names that exactly resemble the keywords.

Keywords of C programming

Auto Break Case Char Const Continue Default Do

double else enum extern Float For goto if

int long register return short signed size of static

struct switch typedef union unsigned void volatile while

C constants

Primary constants Integer constant Real constant Character constant String constant

Secondary constants

Arrays Pointers Structure Union Enum

1. 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: +194.143, -416.41 2. 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. Example: 1990, 194, -394

3. 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: 'T', '9', '$' 4. STRING CONSTANT : It is collection of characters enclosed in double quotes. It may contain letters, digits, special characters and blank space. Example: "Techno well Web Solutions, Sangli"

An entity that may vary during program execution is called a Variable Variables names are names given to locations in memory This locations can contain integer, real or character constants. For Eg: An integer variable can hold only an integer constant, a real variable can hold only a real constant & a character variable can hold only a character constant.

a) A variable name in any combination of 1 to 31 alphabets , digits or underscores. some compilers allow variable names whose length could be up to 247 characters.still, it would be safer to stick with the rule of 31 characters. Do not create unnecessarily long variable names as it adds to your typing effort b) The first character the variable name must be an alphabet or uderscore

c) NO commas or blanks are allowed within variable name d) No special symbol other than a underscore be used in a variable name for Eg: si_int m_hra pop_e_89

Você também pode gostar