Looping in C Programming Language

 Looping in C Programming Language Use: When we want to perform specific task repeatedly then we can use looping. In C Language there are three type of loop: For Loop While Loop Do while Loop Nested for Loop Each Loop statement requires three things: Initialization  Test Condition Increment/Decrement Operation 1. For Loop: For Loop is a repetition control structure which allow us to write a loop that is executed a specific number of time. Syntax:               for( initialization ; test condition; increment/decrement operation)                 {                    ------                    body of for loop;                    ------               } 2. While Loop: While Loop is use to per to p...

Tokens in C Language

 TOKENS IN C PROGRAMMING LANGUAGE


  • Smallest individual unit of C Program is known as Token.
  • There are Six types of tokens:

    

1. KEYWORD:
  • In C Program a word which has fixed meaning is called keyword.
  • During program its meaning is not changed.
  • All keyword are in lower-case.
  • There are 32 keywords:    


2. IDENTIFIER:
  • Identifier is a name of variables and user defined function.    
        Rules of Identifier:
  • It can be in lower case or upper case. Ex. int total; , int TOTAL;.
  • It includes alphabets, numbers, underscore. Ex. int no1;.
  • It doesn't start with number/digit. Ex. int 1no;--(wrong) , int _no;--(right).
  • It doesn't contain white space. Ex. int stu no;--(wrong) , int stu_no;--(right).
  • It can't use a keyword. Ex. int void;--(wrong).
  • We can give 31 letters.

3.CONSTANTS:


Constant: 
  • Constant is a fixed value which can't be changed during the execution of program.
  • There are three types of constants:
  1. Numeric Constants
  2. Character Constants
  3. Backslash Character Constants        

1.NUMERIC CONSTANT:

Numeric Constant has two part:
  • Integer
  • Real
    A. Integer:
  •  Integer numbers contain numbers from 0 to 9.
  • It doesn't contains numbers with fractional part (Floating Point). 
    • Decimal Numbers:
      • Decimal numbers contains number from 0-9, +&- sign can be given at prefix position (Starting).
      • We can't use special symbols.
      • Example:
        • a=79;
        • b=-25; 
    • Octal:
      • It contains digit from 0-7.
      • It starts with 0.
      • Examples:
        • a=037;
        • b=047;    
    • Hexa Decimal:    
      • Hexa Decimal contains digit from 0-9 and characters from A-F.     
      • It starts with ox.
      • Example:
        • a= ox45;
        • b= ox98f;
    B. Real:
  • Real Constants contains digit from 0-9 with fractional part (Floating Point).
  • -&+ sign can be allow at prefix position.
  • Example:
    • a= 25.40;
    • b= .95;

2.CHARACTER CONSTANT:
  • Character Constant can be single character or string character.
    • Single Character Constant:
      • Single Character Constant contains single character. It is represented by single quote.
      • Example:
        • char c='A';
    • String Character Constant:
      • String is a set of character.
      • C Language does not support string data type.
      • To declare string, we can use character array.
      • Example:
        • char c[6]="India";

3.BACKSLASH CHARACTER CONSTANT:
  • Backslash character constant are used in output function for display purpose.
  • It is a specified by \ and single character.


4. STRING:
  • String is a set of character.
  • C Language does not support string data type.
  • To declare string, we can use character array.
  • Example:
    • char c[6]="India";

5. SPECIAL SYMBOLS:
  • Special Symbols are use to follow syntax of C program. If we don't follow this syntax then error will be occurred.
  • Example:
    • {}
    • ()
    • #
    • ;

6. Operators:
  • Operators are use to perform any operations on different operands.
  • Operands can be values or variable.
  • C support 8 operators like Arithmetic operator, Relational operator, Logical operator etc...
  • Example:
    • + , - , * , / , % , == , = , >= , <= are examples of operators.


Comments

Popular posts from this blog

Data Types in C Program

Different Modules to solve the program/problem

Operators in C Program