C LANGUAGE BASICS

Lets begin our journey in C language .…….


Understanding C language is very easy and interesting . All you need to know is basic fundamentals properly.
It is very similar to understanding english language as -:
In English language we first learn alphabets , then form words from them , and then sentences and from sentences a paragraph. Similarly , while learning C we first study alphabets, digits and special symbols , then constants , variables and keywords and then instructions are formed resulting in formation of program.




Let’s understand them one by one-:

 1.) Alphabets, Digits, Special Symbols -:

                                                            These are basic character set .


         Alphabets                   A,B,……..,Z
                                            a,b,……….,z

          Digits                         0,1,2,3,4,…….,9

          Special Symbols         >,<,:,;,",'*,&,^,%,$,# 


 2.) Constants,Variables and Keywords -:   

       Constants -:                                                                                                                       As we all know constants are those whose value  cannot be           changed . They are divided into two categories-:


       a.)Primary constants
       b.)Secondary constants
                             
                            They are shown below by pictorial representation-:


       

                                                                     

-> Integer Constants -: Simply saying integer constants are integers . There are some rules for making
     integer constants . They are-:

  1. Integer constants must have single digit .’
  2. It can be positive, negative or  zero.
  3. It must not have decimal points.
  4. Range of integer constants vary from compiler to compiler . For compilers like Turbo C , Turbo C++ , range is -32768 to +32767. For Visual studio code, GCC range is -2147483648 to +2147483648.    
     Example-: 344
                     -204
                     +9456

-> Real Constants -: They are also called Floating point constants . There are some rules for constructing real constants . They are -:
   
      1.It must have a decimal point.
      2.No commas or blanks are allowed within real constants
      3.It could be either positive or negative.

      Example-: +8845.25
                      -42679.50
                       90.0

 The real constants can be expressed in exponential form if value of constants   is either too small or too large. In exponential form , the real constants is         represented in two parts part appearing before”e” is called mantissa , and part   following e is called exponent.
 Exponential form of 0.000342 is written as 3.42e-4.
  
 Example-: +3.2e-5
                  4.48e-7

-> Character Constant -: As name suggest it contain character . It contain single alphabet, single digit, or a singe special symbol enclosed within single inverted commas.
Here both the commas should point toward left.

Example-: ‘p’
                ‘q’
                ‘1’
                 ‘+’

Variables-: 

                   A variable is a name which can be any word formed by A to Z   alphabets ,digits or underscore. Here we need to note that same variable can hold same type of value . For example integer variable can store only integer constant , float variable can store only float constant. 

Example -: int sum;
                 float average;

In this sum, average are variables which hold integer and float value respectively. There are some rules for making variable names -:

  1. There should be no commas or blanks in variable name.
  2. First character in variable name must be alphabet or underscore(_).

No special symbols except underscore is allowed in variable name.

Example-: sum_num
                si_int 
Are valid variable names . 

Keywords-:

                   Keywords are some words in C whose meaning is already explained to compiler. Here we should note that C language keywords should not be used in place of variables . Keywords in C are unique and there meaning is unique . There are 32 keyword in C . Some of them are mentioned below-:

int                      if                  break
float                   for                char
return                switch           do
signed               auto              while
goto                  continue        void
  
In next we will study our first program in C language.

             

Leave a comment

Create a website or blog at WordPress.com

Up ↑

Design a site like this with WordPress.com
Get started