Introduction to C Language

What is language? A medium/way of interaction between any two communicating devices/persons. Example: Hindi, English etc.

Computer Language: A medium/way of interaction between users/people and computers/smart devices. Example: C , C++, Java, Python etc. With a computer language, we are able to tell computers what to do, how to do, when to do etc.

What is C language?

C programming is a general-purpose, procedural computer programming language developed in 1972 by Dennis M. Ritchie at the Bell’s Laboratories to develop the UNIX operating system. C is the most widely used computer language. It keeps fluctuating at number one scale of popularity along with Java programming language, which is also equally popular and most widely used among modern software programmers

Why use C?

  1. Easy to learn
  2. Structured language
  3. It produces efficient programs
  4. It can handle low-level activities
  5. It can be compiled on a variety of computer platforms

Learning English: Alphabets->Words-> Sentence -> Paragraph ->Essay/Story

Learning C: Character Set->Tokens-> Statement -> Program ->Project/Software

Character set: It is the set of allowed characters in C language. Each character can be used for programming in C. The set of valid character in C language are:

  1. Alphabets- (Uppercase and Lowercase letters: A to Z, a to z)
  2. Digits-(0-9)
  3. White space character (blank space, tap space, new line etc.)
  4. Symbols – # , + , – , * , / , % , < , > , = , & , : , ! , \ , ? , ; , . , () , {}, [] ,etc.

Tokens: It is the smallest individual unit in a program. It is a valid combination of characters. Valid means meaningful or having some purpose i.e. it make sense to the program.

Types of Tokens-

  1. Keyword/Reserve words
  2. Identifier
  3. Literal/Constant
  4. Operator
  5. Punctuators/separators

1. Keywords are the words already defined in the C language i.e their meaning is already defined for the compiler. Example- int, float, char, double, void, if, else, for, while, do, switch etc. There are 32 keywords in C language.

autobreakcasecharconstcontinuedefaultdo
doubleelseenumexternfloatforgotoif
intlongregisterreturnshortsignedsizeofstatic
structswitchtypedefunionunsignedvoidvolatilewhile

2. Identifier are the names given to the elements of the programs like variables and functions, arrays, structure.

Rules for identifiers :-

  1. It is any valid combination of only alphabets , digits and underscore(_)
  2. No other symbol is allowed, not even space.
  3. It must not start with a digit . It must start only with an alphabet or underscore.
  4. It cannot be a keyword .
  5. It is case sensitive i.e uppercase and lowercase names are different.

Examples:

  1. roll no (space not allowed invalid)
  2. roll_no (valid)
  3. rollno (valid)
  4. marks1(valid)
  5. 1marks( invalid must not start with a digit )
  6. int(invalid) – int is a keyword)
  7. Int(valid)
  8. INT(valid)

Note:- Upper case and lower case letters are treated differently as C is a case sensitive language .

3. Literal / constant is a fixed value which cannot be changed during the program execution. Example: pi=22/7= 3.14 in maths

4. Operators are the symbols that performs some operation / calculation. C has a wide range of operators to perform various operations. Example + ,- ,* ,/ etc

2 + 3 = 5

2 – 3 = -1

2 * 3 = 6

4 / 2 = 2 etc.

5. Punctuators and Separators: are used to separate program elements. Examples:

  1. #
  2. ;
  3. ,
  4. :
  5. .
  6. ‘ ‘
  7. ” ”
  8. ( )
  9. { }
  10. [ ] etc

error: You can only copy the programs code and output from this website. You are not allowed to copy anything else.