Learn C Language | Introduction of C Language for Beginners

Introduction of C Language

C is a general-purpose high level language that was originally developed by Dennis Ritchie for the Unix operating system. It was first implemented on the Digital Equipment Corporation PDP-11 computer in 1972. The Unix operating system and virtually all Unix applications are written in the C language.

Introduction of C Language for Beginners
Father of C Language


History of C Language:

History of C Language: In the mid-1960 there was a need for a language that can handle all basic applications with scientific purpose and it introduced the language called BCPL(Basic Combined Programming Language) developed by Mortein  Richard at Cambridge University USA. BCPL was less powerful, to specific that’s why the language has B was developed at AT & T (American Telephone And Telegram) Bell Laboratory USA by Ken Thompson in 1969.But like BCPL, this language is also very specific and at last in a 1972 the programmer name Dennis Ritchie develop language by C  at AT & T Bell Laboratory USA which is general purpose programming language that can deal with all application.


            C is a Procedure Oriented Programming Language which is also called as Middle level Programming Language.This is because; it has good Programming efficiency as well as machine efficiency. At the developing time C language developed in UNIX Operating System and today we use MS-DOS for C Programming. For the C Programming Language there is two compilers exsiccating the C Programs i.e.

          i. Borland-C
         ii. Turbo-C    

What is tokens and what are the types of tokens ?

TokensEvery meaningful entry i.e individual words and punctuation marks in a program called as tokens. Collection of tokens knows as C program. 

Types of tokens:

  • Keywords
  • Identifiers
  • Constants
  • Operators
  • String
  • Variables

Keywords

Keywords: Keywords are reserved words, the meaning of the word already known to the ‘C’ compiler. These are the pre-defined words already defined by the C developer i.e. These words refer to a process for a particular task. In C language there are a total 32 keywords and all keywords written in small case letters. Because C language is case sensitive language. Following are the list of ‘C’ keywords use in Turbo ‘C’ compiler:


auto
else
int
sizeof
break
double
long
typedef
case
enum
register
struct
char
extern
return
union
continue
for
short
while 
do
goto
signed
volatile
default
if
unsigned
switch
static
void
float



Identifiers

Identifiers: Identifiers refers to the name of user-defined variables, array and functions. A variable should be essentially a sequence of letters or digits and the variable name should begin with a character.
Both uppercase and lowercase letters are permitted. The underscore character is also permitted in identifiers.

The identifiers must conform to the following rules.
  • First character must be a alphabet.
  • Identifier names must consist of only letters digits and underscore.
  • An identifier name should have less than 31 character.
  • Any standard C language keyword cannot be used as a variable name.
  • Identifier should not contain space.



Constants

Numeric Constants: Numeric Constant which refers sequence of digit with or without sign.
                                   Ex: 10, -25, 3.5, -2.7 etc
  • Integral Constants: Integral constant which refers the sequence of digit without decimal point with optional sign. Ex: 25, -46 etc
  • Real Constants: Real constant which refers to the sequence of digit i.e hole number, it containing decimal point. These present fractional part with or without sign. Ex: 3.14, -.3.7 etc
  1. Real Constant Expressed in Decimal Notation: Real constant which refers to the sequence of digit i.e hole number, it containing decimal point. These present fractional part with or without sign. Ex: -3.14, -.3.7 etc
  2. Real Constant Expressed in Scientific Notation: It refers to scientific notation i.e Exponential Mantissa Exponent where mantissa is either integer or real number with or without sign. Ex: -2.5 E + 25 etc
Character Constants:
  • Single Character Constant: Any single character from C character set enclosed within the pair of single quotation mark (' ') and in C language they represent there ASCII Ex: 'p', 'R', '9' etc Where character may be alphabet, digits and white spaces.
  • String Constant: Set of character or group of character or sequence of character enclosed within the double quotation mark (" ") is knows as string constant. Characters may be alphabet, digit and white spaces. Ex: "C_Programming", "Blog", "2020" etc

Variable

Variable: Variable is a data-name that store a data-value. Variable is a quantity whose values changes during execution of program. Variable is memory location name given by the programmer for storing the value. Variable is hold constant.

Operators


Operators:C operators can be classified into a number of categories. They include.


  • Arithmetic Operators
  • Relational Operators
  • Logical Operators
  • Assignment Operators
  • Increment and Decrement Operators
  • Conditional Operators
  • Bit-wise Operators
  • Special Operators

Arithmetic Operators







Operator
Meaning
+
Addition or unary plus
-
Subtraction or unary minus
*
Multiplication
/
Division
%
Modulo division




Relational Operators:


Operator
Meaning
<
Is less than
<=
Is less than or equal to
>
Is greater than
>=
Is greater than or equal to
==
Is equal to
!=
Is not equal to


Logical Operators

Logical Operators: The operator which combines two or more relational expression called as logical expression and the expression which contains it is called as logical operators. The value of logical expression depends on the value of all relational expression and the logical operator that combines then together. C has following logical operators.
  • && - Logical AND
  • || - Logical OR
  • ! - Logical NOT or Negation

Assignment Operators



Assignment Operators: This operator is used to assign a value to the variable. Operators is used for assigning a result of an expression to the variable. C uses '=' for assignment operator that uses to assign the value on its right to the left side variable.

Syntax:

Variable = Value ;

Increment and Decrement Operators

Increment and Decrement Operators: In C language '++' is called as increment operator. i.e '++' increase the value in an operand by 1 same for '--' i.e '--' is the decrement operator, to decrease the value from operand by 1. Both the '++' and '--' are unary operators. The following form '++m' or 'm++' and '--m' or 'm--'.
The above both the forms i.e '++m' or 'm++' means a same thing is value incremented by in an operand means m=m+1 same for the '--m' or 'm--' meaning is m=m-1 this operators are generally used in looping statement.

Conditional Operators

Conditional Operators: C uses Ternary operators ?: (Question mark Colon) knows as conditional operator and it is also called as ternary operators. For the use of conditional operator to follow following syntax:-
Var = (exp1? exp2 : exp3);

Bit-wise Operators

Bit-wise Operators: In C it has special operators knows as bit-wise operator for manipulation of data at bits or shifting then right or left.

Operator
Meaning
&
Bit-wise AND
|
Bit-wise OR
^
Bit-wise exclusive OR
<<
Shift left
>>
Shift right

Special Operators
  • Coma Operators: The coma operator is the related expression together. A coma link list of expression becomes the value of left.
                                        Syntax:
Var = (exp1, exp2, exp3);
e.g C= (a=10, b=20, a+b) ;


  • Sizeof Operators: A sizeof operator is a compile time operator and when use with an operator it return a number of bits. The operators occupies the operands size, operands may be variable, constant or datatype.
e.g   n= sizeof(a);
        n= sizeof(int);
                      The size of operator is normally used to determine the length of array's and structure. There size are not known to the programmer it is also used to allocate memory dynamically to the variable during execution of a program.

Post a Comment

Previous Post Next Post