C language preliminaries
C language preliminaries
PRELIMINARIES
INTRODUCTION
C is a high level language. It is both
general purpose and a specific purpose
programming language.
C is the most popular and common
programming language for every
application developer.
C is invented by Dennis Ritchie.
CHARACTERISTICS OF C
C is a general purpose programming language.
C is structured programming language.
Helps in development of system software.
It has a rich set of operators.
It provides compact representation for expressions.
No rigid format. Any number of statements can be typed
in a single line.
Portability. Any C program can be run on different
machines with little or no modifications.
Supports a rich set of data types.
Very less number of reserved words.
APPLICATIONS OF C
System software
Operating systems
Interpreters
Compilers
Assemblers
Editors
Loaders
Linkers
Application software
Database Management system
Graphics packages
Spread sheets
CAD/CAM applications
Word processors
Office Automation Tools
Scientific and Engineering applications
CHARACTER SET
The characters used in C language are
grouped in into following three
categories:
Alphabets
Digits
Special characters
Alphabets Upper letters case A-Z
Lower letters case a-
z
Digits 0 through 9
, Comma
. Period
Special characters: Colon
; Semicolon
# Hash
& Ampersand
~ Tilde
\ backslash
C TOKENS
The basic and smallest units of a C
program are called C tokens. There are
6 types of tokens in C. They are:
Keywords
Identifiers
Constants
Strings
Operators
Special symbols
KEYWORDS AND
IDENTIFIERS
Every word in a C program is either a keyword or an
Identifier
IDENTIFIERS
Identifiers are names given to the program elements such
as variables, arrays and functions.
Rules for Forming Identifier Names
The first character must be an alphabet or an underscore.
All succeeding characters must be either letters or digits.
Uppercase and lowercase identifiers are different in C.
No special character or punctuation symbols are allowed
except underscore “_”
No two successive underscores are allowed
Keywords should not be used as identifiers.
BASIC STRUCTURE OF C
PROGRAM
The basic components of C
program are:
main ()
A pair of curly braces { }
Declarations and statements
User-defined functions
Structure of a C program:
preprocessor statements
Global declarations;
main()
{
declarations;
statements;
}
user defined function
EXAMPLE PROGRAM
TO DISPLAY HELLO WORLD
#include<stdio.h>
void main()
{
printf(“Hello world”);
}