Professional Documents
Culture Documents
C Language
C Language
In 1978, Brian Kernighan and Dennis Ritchie produced the first publicly available
description of C, now known as the K&R standard.
Why to use C:
C language is used for developing system applications that forms major portion of
operating systems such as Windows, UNIX and Linux. Below are some examples
of C being used.
Database systems
Graphics packages
Word processors
Spread sheets
Operating system development
Compilers and Assemblers
Network drivers
Interpreters
Features of C language:
Middle level
languages don’t Low level
High level
provide all the languages
languages
built-in provides
provides almost
functions found nothing other
everything that
in high level than access
1 the programmer
languages, but to the
might need to
provides all machines
do as already
building blocks basic
built into the
that we need to instruction
language
produce the set
result we want
Examples:
2 C, Assembler
Java, Python
Structure Object
S.no Non structure
oriented oriented
Prime focus is
Prime focus is on the data
on functions that is being
2 and procedures operated and N/A
that operate on not on the
data functions or
procedures
Data moves
Data is hidden
freely around
and cannot be
the systems
3 accessed by N/A
from one
external
function to
functions
another
Program Program
structure structure
4 follows “Top follows N/A
Down “Bottom UP
Approach” Approach”
Examples:
C++, JAVA BASIC,
5 C, Pascal, and C# (C COBOL,
ALGOL and sharp) FORTRAN
Modula-2
Example:
Date : 01/01/2012
*/
#include <stdio.h> /* Link section */
int total = 0; /* Global declaration and definition section */
int sum (int, int); /* Function declaration section */
int main () /* Main function */
{
printf ("This is a C basic program \n");
total = sum (1, 1);
printf ("Sum of two numbers : %d \n", total);
return 0;
}
int sum (int a, int b) /* User defined function */
{ /* definition section */
return a + b;
}
C – Data Types
C data types are defined as the data storage format that a variable can store
a data to perform a specific operation.
Data types are used to define a variable before to use in a program.
Size of variable, constant and array are determined by data types.
C – data types:
Enumeration data
2 Enum,typedef
type
Digits : 0 1 2 3 …9
%d : prints integer
%f : prints float
%c : prints character
%s : prints string
Char---------------1 bytes-------------------------%c
Float---------------4 bytes--------------------------%f
Double-------------8 bytes----------------------- %f
C Tokens:
and operators.
each word has different meaning, these can not used as names of
Ex: auto, for, switch, do, while, case, else, goto etc.
float a=2.35;
char c=’a’;
Escape
Meaning
sequence
\\ \ character
\? ? character
\a Alert or bell
\b Backspace
\f Form feed
\n Newline
\r Carriage return
\t Horizontal tab
\v Vertical tab
Keywords:
The following list shows the reserved words in C. These reserved words may not be used as
constant or variable or any other identifier names.