![]() | |||||
Getting started with C |
Getting started with C
C is a programming language. C Language Designed and written by Dennis Ritchie, in AT & T's Bell laboratories of U.S.A. in 1972.
Question: why C seems so popular ?
Ans: because it is reliable, simple and easy to use. Moreover, in an industry where newer languages, tools and technologies emerge and vanish day in and day out, a language that has survived for more than 3 decades has to be really good.
Program
A group of instructions can then be combined to form a program.
Identifier:
1. Constant:- A Constant is an entity that doesn't change.
2. Variables:- Variables are the name of memory locations where we store data. It may change.
3. Keywords:- A keywords is a word that carries special meaning. There are 32 keywords in C Language.
Type of Constants in C
It is devided into two major categories :
Primary Constants
Secondary Constants
constants in C |
Rules for constructing Integer Constants
An integer constant must have at least one digit.
It must not a decimal point.
It can be zero, positive or negative.
If there is no sign precades an integer constant, then it is assumed to be positive (+).
No commas or blanks are allowed within an integer constant. Example: Sum (✓), Su,m or S u m (X)
The allowable range for integer constant is : (-2147483648 to +2147483648). But this range is depend on compiler.
example: 583, +736, -42675
Rules for constructing Real Constants
Constructing Real constant expressed in fraction form
A real constant must have at least one digit.
It must have a decimal point.
It could be positive or negative.
Default sign is positive(+).
No commas or blanks are allowed within an real constant.
example: +452.768, 763.00, -76.53, -845.9654.
Constructing Real constant expressed in exponential form
Mantissa part and exponential part should be separated by a letter which is e or 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 +ve.
Range of real constant expressed in exponential form is : (-3.4e38 to +3.4e38).
Note:- The part appearing before e called mantissa.
Example: 0.000563 can be written as- 5.63e-4 (It means 5.63 x 10-4 ).
Rules for constructing Character Constants
A Character constant is a single alphabets, a single digit or a single special symbol enclosed within single inverted comma.
example: 'A' , 'T' , '8' , '=' etc.
Rules for constructing Variable Names
A variable name is any combination of 1 to 31 alphabets, digits or underscores. Some Compilers allow variable name whose length could be upto 247 characters.
The first character in the variable name must be an alphabet or Underscore ( _ ).
No special symbol other than an underscore can be used in a variable name.
No commas or blanks are allowed within a variable name.
Example: add_number , avg_of_3 etc.
NOTE:
* Always creat meaningful variable names otherwise you will confuse with the variable names.
example: prin(Principal) , roi(rate of interest) , noy(number of years) etc.
* This type declaration done at the beginning of the program as shown below.
Ex: int si, c_i;
float bassal;
char code;
C Keywords
Keywords are the words whose meaning has already been explained to the C compiler. We can't use keyword as variable name because if we do so we are trying to assign a new meaning to the keyword, which is not allowed by the computer.
There are 32 Keywords available in C Language.
C Keywords |
0 Comments
Please do not enter any spam link in the comment box.