NIELIT COURSE

In this website you will cracked Computer CCC,CCC+,O-LEVEL,etc.


"Education Is The Key To Unlock The Golden Door Of Freedom"

INTRODUCTION TO "C" LANGUAGE


What is Character Set

 ✍Character set is a set of Valid Characters that a language can recognize.The character set in C language consist of the upper and lower case alphabets ,Digit,special Character and white space.There are Two type of character set in c laguage.

1-Source Characters.
2-Execution Character/Escape Sequences.

 Source Character

  source character are entered directly into the source program by typing by the keyboard. They are interpreted by the computer(as the appear on the screen) at
  compile time.These are 4 type.

 (i).Alphabets:-

 (a).Uppercase letters - A-Z
 (b). Lowercase letters- a-z

 (ii).Digits:-

 0,1,2,3,4,5,6,7,8,9

 (iii).Special Character:-

 (iv).White space:-

 Execution Character/Escape Sequences

 Execution Character/Escape Sequences are those character which can not be typed by the keyboard or not display on the screen as such.An Escape Sequences always begins with a Backslash(\).



What is Identifier

 ✍Identifiers are names for entities in a C program, such as variables, arrays, functions, structures, unions and labels. An identifier can be composed only of
 uppercase , lowercase letters, underscore and digits, but should start only with an alphabet(a-z& A-Z) or an underscore(_).
If the identifier is not used in
 an external link process, then it is called as internal Identifiers.


 Rule of constructing Identifiers.

 ✔The first character in an identifier must be an alphabet or an underscore and can be followed only by any number alphabets, or digits or underscores.
 ✔They must not begin with a digit.
 ✔Uppercase and lowercase letters are distinct. That is, identifiers are case sensitive.
 ✔ Commas or blank spaces are not allowed within an identifier.
 ✔ Keywords cannot be used as an identifier.
 ✔ Identifiers should not be of length more than 31 characters.
 ✔ Identifiers must be meaningful, short, quickly and easily typed and easily read.

 Example:-

 ❶Valid Identifiers.  total,sum ,average,_x,y_, mark_1 , x1
 ❷Invalid Identifiers  1x - begins with a digit
       char - reserved word
       x+y - special character

 Note:-Underscore( _ ) character is usually used as a link between two words in long identifiers.

Types of Identifiers.

 C defines two kinds of identifiers:

Internal identifier:- If the identifier is not used in an external link process, then it is called as internal. These identifiers are also known as internal names;
  includes the names of local variables. It has at least 31 significant characters.

External identifier:- If the identifier is used in an external link process, then it is called as external. These identifiers are also known as external names; include
  function names and global variable names that are shared between source files. It has at least 63 significant characters.


What is Variables


 ✍A Variables is an Identifier that is used to represent some specified type of information within a designated portion of a program.Variable holds data that can be modified during program execution.After declare a variable in a program , you can assign it a value.

 Assigning a Name to a variable.

 ✔Variable can consist of any sequences of letters,Digits,and special character.No other special character are allowed.
 ✔The first character of a variable should be a letter(a-z),an Underscore(_).It can be followed by letter,Digit or Underscore.
 ✔Variable name is case-sensitive.That is NUM, num are two different variable. Though uppercase letter are allowed,usually variable in C language are written
  in Lowercase.
 ✔ Reserved word called Keywords.Which convey specific meaning to the compiler of C language cannot be used as a names of identifier or variables.

What is Keywords


 ✍C programs are constructed from a set of reserved words which provide control and from libraries which perform special functions.The Predefine reserved on C language called the Keywords.

Rule of Keywords.

 ➢The keywords are also called ‘Reserved words’.
 ➢Keywords are the words whose meaning has already been explained to the C compiler and their meanings cannot be changed.
 ➢Keywords serve as basic building blocks for program statements.
 ➢Keywords can be used only for their intended purpose.
 ➢Keywords cannot be used as user-defined variables.
 ➢All keywords must be written in lowercase.
 ➢32 keywords available in C.

Types of Keywords.

 Generally in C programming language 32 Keywords are avilables.These keywords are divided in many parts.These are following.....

 ❶Data type Keywords:-

 int    Specifies the integer type of value a variable will hold.
 char    Specifies the character type of value a variable will hold.
 float    Specifies the single-precision floating-point of value a variable will hold.
 double   Specifies the double-precision floating-point type of value a variable will hold.

 ❷Qualifier Keywords:-

 signed    Specifies a variable can hold positive and negative integer type of data .
 unsigned    Specifies a variable can hold only the positive integer type of data.
 short    Specifies a variable can hold fairly small integer type of data.
 long    Specifies a variable can hold fairly large integer type of data.

 ❸Loop Control Structure Keywords:-

 for    Loop is used when the number of passes is known in advance.
 while   Loop is used when the number of passes is not known in advance.
 do    Loop is used to handle menu-driven programs.

 ❹User-defined type Keywords:-

 typedef    Used to define a new name for an existing data type.
 Enum    Gives an opportunity to invent own data type and define what values the variable of this data type can take.

 ❺Jumping Control Keywords:-

 break    Used to force immediate termination of a loop, bypassing the conditional expression and any remaining code in the body of the loop.
 continue    Used to take the control to the beginning of the loop bypassing the statements inside the loop.
 goto    Used to take the control to required place in the program .

 ❻Storage Class Keywords:-

 auto   Memory Till the control remains within the block.
 register   CPU Rrgister Till the control remains within the block.
 static   Memory Value of the variable persists between different function calls.
 extern   memory Till the program’s execution doesn’t come to an end.

 ❼Decision type Keywords:-

 if
 else
 switch
 case
 default

 ❽Derived type Keywords:-

 struct
 union

 ❾Function type Keywords:-

 void
 return

 ❿Other type Keywords:-

 const
 volatile
 sizeof

What is Constants


 ✍Constants in C are fixed value that does not change during the execution of a program. Constants can be of any of the basic data types. C supports several types of constants in C language.

 ❶Numeric Constant:-

 Numeric Constant(literal) has a constant value in number.The value of the constant can be positive and negative numeral.These are two type of numeric constant.

(i)-Integer Constant:-

 In C language they are Decimal,Octal,and Hexadecimal.An integer constant must have at least one digit.

(a)-Decimal integer Constant:-
 ✔ It consists of any combinations of digits taken from the set 0 through 9, preceded by an optional – or + sign.
 ✔The first digit must be other than 0.
 ✔Embedded spaces, commas, and non-digit characters are not permitted between digits.
 Example:  45, -55, 5 etc....


(b)-Octal integer Constant:-
 ✔It consists of any combinations of digits taken from the set 0 through 7.
 ✔If a constant contains two or more digits, the first digit must be 0.
 Example:  045, 0578, 003, 010, 0127 etc.......


(c)-Hexadecimal integer Constant:-
 ✔It consists of any combinations of digits taken from the set 0 through 7 and also a through f (either uppercase or lowercase).
 ✔The letters a through f (or A through F) represent the decimal quantities 10 through 15 respectively.
 ✔This constant must begin with either 0x or 0X.
 Example:  0X58, 0XFF, 0X1C, 0X0, 0X3, 0X15, -0X57 etc.....

(ii)-Real Constant:-

(a)- Use of Real or Floating-point constants:-

 Integer numbers are inadequate to represent quantities that vary continuously, such as distances, heights, temperatures, prices and so on. These quantities are
 represented by numbers containing fractional part. Such numbers are called real or floating point constants.


(b)-Express a real constant in Exponential form:-

 A real constant is combination of a whole number followed by a decimal point and the fractional part. If the value of a constant is either too small or too
  large
, exponential form of representation of real constants is usually used.

 In exponential form, the real constant is represented in two parts.

 Mantissa:-The part appearing before e, the mantissa is either a real number expressed in decimal notation or an integer.

 Exponent:-The part following e, the exponent is an integer with an optional plus(+) or minus(-) sign followed by a series of digits .The letter e separating the
  mantissa
and the exponent can be written in either lowercase or uppercase.


 Example:- 0.000342 can be represented in exponential form as 3.42e-4

7500000000 can be represented in exponential form as 7.5e9 or 75E8


 The Real Constant to Represent number containing fractional parts.

 ✔It is allowed to omit digit before or after the decimal points..Exp:25. ,.45,-.55 etc...
 ✔Real constant also represented in exponential notaion.
 ✔It must have a decimal point.
 ✔It could be either positive or negative.
 ✔Commas or blanks are not allowed within a real constant.
 ✔Exponent can be represented by 'e' or 'E' Exp: e2 represent 10̂2
 ✔White space is not allowed between fraction part.Exp: 10e  5(not valid..extra space not allowed).
 Note:-Legal Real constant 0.6E2 ,42e-5 ,3.28e5 ,-43.e-5

 ❷Character Constant:-

 Character constant is either a single alphabet or a single& string.

(i)- Single Character Constant:-

 Character constant is either a single alphabet or a single digit,or single special symbol enclosed within a pair of a single quotation mark..Exp:-  'A', 'a', '.', '?'

(ii)- String Constant:-

 A string constant or literal is a sequence of Alphanumeric characters enclosed in Double Quotation(")marks. The maximum length of string constant is
  limited to 255 Character.Each string constant is automatically added with terminating character '\0'.Thus the string "abc" will actually be represented as
"abc\0".

 Note:-Example of String constant:."The total marks=", "Rs 2000.00", "Hello!computer", "34.557".

 ❸Backslash Character constants:-

 Each Character has unique ASXII value.These are Non-Printable character.

 ❹Symbolic constants:-

 A symbolic constant is a constant that is represented by Name(symbol) in the program.A symbolic constant also does not change its value.

 ✔No space is allowed between # and the word.
 ✔#define must not end with semi-colon(;).
 ✔symbolic name cannot be assigned other value.

 Note:-Legal Declaration.... #define a 2, #define PI 3.14

 Invalid Declaration....#define a=2 //no.C.E.//warning, #define a 2;//No C.E.