Anda di halaman 1dari 4

Basic of C

C Language The C language is one of the powerful programming languages used to


write computer programs for variety of applications. It was developed by Dennis Ritchie
at Bell Lab during 1970s. C has flexible features to write programs for numerical,
commercial and graphical applications. May operating system programs for the latest
computers and compilers are written using C language.
This language was developed from B language which was modified from a
language called Basic Combined Programming Language (BCPL).

Salient features of C:
C is a general purpose, structured programming language. Among the two types of
programming languages discussed earlier, C lies in between these two categories. Thats
why it is often called a middle level language. It means that it combines the elements of
high level languages with the functionality of assembly language. It provides relatively
good programming efficiency (as compared to machine oriented language) and relatively
good machine efficiency as compared to high level languages). As a middle level
language, C allows the manipulation of bits, bytes and addresses the basic elements with
which the computer executes the inbuilt and memory management functions. C code is
very portable, that it allows the same C program to be run on machines with different
hardware configurations. The flexibility of C allows it to be used for systems programming
as well as for application programming.

C is commonly called a structured language because of structural similarities to


ALGOL and Pascal. The distinguishing feature of a structured language is
compartmentalization of code and data. Structured language is one that divides the entire
program into modules using top-down approach where each module executes one job or

task. It is easy for debugging, testing, and maintenance if a language is a structured one. C
task. It is easy for debugging, testing, and maintenance if a language is a structured one. C
supports several control structures such as while, do-while and for and various data
structures such as strucs, files, arrays etc. as would be seen in the later units. The basic
unit of a C program is a function - Cs standalone subroutine. The structural component of
C makes the programming and maintenance easier.

Characters used in C
Alphabets
Upper case letters A to Z
Lower case letter a to z

Numbers
0 to 9

Special Characters

+ Plus Double Quote


- Minus & Ampersand
* Asterisk # Hash
/ Slash $ Dollar
\ Back slash ^ Caret
% Percent < Lesser than
| Vertical bar > Greater than
~ Tilde = Equal to
? Question mark ( Open Parenthesis
! Exclamation Mark ) Close Parenthesis
, Comma [ Open bracket
. Full stop ] Close Bracket
; Semicolon { Open Set Bracket
: Colon } Close Set bracket
Apostrophe _ Underscore

Identifier An identifier is a name having a few letters, numbers and special character
_ (Underscore). It is used to identify a variable, function, symbolic constant and so on. An
identifier can be written with a maximum 31 characters. It is a good practice to have

identifiers with few letters; less than 8 letters is commonly followed with the first letter
identifiers with few letters; less than 8 letters is commonly followed with the first letter
being an alphabet.
Ex:-
c3
sum
PI
sigma
matadd

Rules for Forming Identifiers -


Identifiers are defined according to the following rules:
1. It consists of letters and digits.
2. First character must be an alphabet or underscore.
3. Both upper and lower cases are allowed. Same text of different case is not
equivalent, for example: TEXT is not same as text.
4. Except the special character underscore ( _ ), no other special symbols can be used.

Keywords or Reserved words C language uses the following keywords which are
not available to users to use them as variables/function names. Generally all keywords are
in lower case although uppercase of same names can be used as identifiers.

auto break case enum


volatile while char extern
switch typedef const struct
short union continu return
e
signed unsigne register goto
d
sizeof void for if
static float double int
default do else long

Tokens There are six types of tokens are used in C language.

C Tokens Examples

Keywords Auto, float, int etc


Constants -25, 3.24 etc

Identifiers Sum, PI etc


Identifiers Sum, PI etc
String literals Total Amount is Sum =
etc
Operators +, -, * etc
Separators , : ;

Watch Video Tutorial Click Below

Like it ? Share it.

Anda mungkin juga menyukai