computer science

Constants, Variables and Keywords 
Constants, Variables and Keywords

The alphabets, numbers and special symbols when properly combined form constants, variables and keywords. Let us see what are ‘constants’ and ‘variables’ in C. A constant is an entity that doesn’t change whereas a variable is an entity that may change.

Types of C Constants:-
C constants can be divided into two major categories:
(a)     Primary Constants
(b)     Secondary Constants
                                                                     
                                                                             

                           Constants
                                   
Primary Con                         Secondary Con
  Integer Constant                Array
  Real Constant                      Pointer
  Character Constant            Structure
                                                 Union
                                                 Enum,etc.   
                         
Types of C Variables
As we saw earlier, an entity that may vary during program execution is called a variable. Variable names are names given to locations in memory. These locations can contain integer, real or character constants. In any language, the types of variables that it can support depend on the types of constants that it can handle. This is because a particular type of variable can hold only the same type of constant. For example, an integer variable can hold only an integer constant, a real variable can hold only a real constant and a character variable can hold only a character constant.

C Keywords
There are only 32 keywords available in C.


The First C Program
 simple interest
          \* simple interest to calculate*\ this is comment
                 #include<stdio.h>
                 #include<conio.h>
                 int main()
                 {
                           int p, n ;
                           float r, si ;
                            p = 1000 ;
                            n = 3 ;
                            r = 8.5 ;
                 /* formula for simple interest */
                            si = p * n * r / 100 ;
                            printf ( "%f" , si ) ;
                            }
                             
C Tokens:--
The tokens of a language are the basic building blocks that can be put together to construct programs. A token can be a reserved word (such as int or while), an identifier (such as b or sum), a constant (such as 25 or "Alice in Wonderland"), a delimiter (such as } or ;) or an operator    (such as + or =).
 For example, consider the following portion of Program P1.4 given at the end of the last chapter:
int main()
 {
int a, b, sum;
a = 14;
b = 25;
sum = a + b;
printf("%d + %d = %d\n", a, b, sum);
}
      Starting from the beginning, we can list the tokens in order:
token                       type
int                          reserved word
main                      identifier
(                             left bracket, delimiter
)                              right bracket,delimiter
{                             left brace, delimiter
int                           reserved word
a                             identifier
,                              comma, delimiter
b                             identifier
,                              comma, delimiter
sum                         identifier
;                              semicolon, delimiter
a                             identifier
=                            equals sign, delimiter
14                          constant
;                             semicolon, delimiter.      

Integer Expressions
An integer constant is written in the manner we are all accustomed to: for example, 354, 639, -1, 30705, and -4812. Note that you can use only a possible sign followed by digits from 0 to 9. In particular, you cannot use commas as you might do to separate thousands; thus 32,732 is an invalid integer constant—you must write it as 32732. An integer expression can be written using the following arithmetic operators:
                                              + add
− subtract
* multiply
/ divide

% find remainder