PROCEDURE ORIENTED PROGRAMMING:
*COBOL,FORTRAN and C is commonly known as procedure
oriented programming.
*In POP, the problem is
viewed as sequence of things to be done such as reading,calculating and
printing.
*It is a top down approach.
HISTORY
OF C:
*The first computer language was ALGOL introduced in
1960.It is a structured programming.
*Martin Richards developed a language
called as BCPL(Basic Combined Programming Language) in 1967.
*Ken Thompson created a language
using many features of BCPL and called as B.
*B was used to early version of UNIX
operating system at Bell Laboratories.
*Both B and BCPL were Typeless system
programming languages.
*C language was evolved from ALGOL,BCPL
and B languages by Dennis Ritchie at the Bell Laboratories in 1972.
*C uses many concepts from these languages and added the
concept of Data types end other powerful features.
*In 1983 ANSI(American National
Standards Institute) appointed a technical committee defined a standard for C.
*The committee approved a version of
C in December 1989 which is known as ANSI C also referred as C89.
*Then it was approved by ISO.
*Current version of C is C99.
IDENTIFIER:
*An identifier is a symbolic name used to refer to an
entity.Such as Data type,Constant,Variable,Function,Array etc in a program.
VARIABLE
AND CONSTANT:
*Variable is an identifier
used for storing data in a program. The value of the variable may be changed
during execution of the program.
*Constant is a fixed value. It never
changes its value during execution.
Types
of Constants:
1)Integer Constants(123,-321,xbcd)
2)Real Constants(92.3,0.65e4)
3)Single character
Constants('5','x',';')
4)String
Constants("hello","1087")
5)Backslash
Constants('\t','\n')
SCALAR
DATA TYPE AND DERIVED DATA TYPE:
*A Scalar data type is used for representing a single value
only.
Such as int,float,char,double.
*A Derived data type is used
for representing a single value or multiple value.
* It is derived from Scalar
data type. Such as Array,Structure,Union and Functions.
TOKEN:
*Token is a individual entity of a program. A compiler
identifies and splits a program
into no of tokens.
C has six types of tokens.
1)Keywords
2)Identifier
3)Constants
4)Strings
5)Special symbols
6)Operators
KEYWORDS:
*All Key words have fixed meanings and
these meaning cannot be changed.
ANCI C has defined 32
keywords.
C99 has added 5 more
keywords.
1)_Bool
2)_Complex
3)_Imaginary
4)inline
5)restrict
OPERATOR
AND OPERAND:
*An operator is a symbol that tells a
computer to perform certain mathematical or logical manipulations.
CLASSIFICATION
OF OPERATORS IN C:
1)Arithmetic operator(+,-,*,/,%)
2)Relational
operator(<,<=,>,>=,==,!=)
3)Logical
operator(&&-AND,||-OR,!-NOT)
4)Assignment operator(=)
3 types of
assignments:
i)Simple assignment(a=10)
ii)Compound
assignment(a+=5)
iii)Assignment(a=b=c=0)
5)Increment and Decrement
operators(++,--)
The execution
of n++ is much faster than execution of n=n+1.
n++
requires single machine instruction but n=n+1 requires more instructions to
carry out this operation.
6)Conditional operators()
7)Bitwise operators(&-bw AND,|-bw
OR,^-bw EXOR,<<-shift left,>>-shift right)
8)Special operators
(comma,sizeof)
EXPRESSION:
*A valid combination of
constants,variables,and operators constitutes an expression.
DATA
TYPES:
*ANCI C supports three classes of data
types
1)primary or
fundamental data type
2)Derived data
type(Array,Functions,Pointers)
3)User defined
data type(Structures,Unions,Enumerations)
1)primary data types:
1)Integer has two
types.
1)Signed(short int=1 byte,int,long int=4 byte)
2)Unsigned(Unsigned short int,unsigned int,unsigned long int)
2)Float has three
types:
1)float=4 byte
2)double=8 byte
3)long double =10 byte
3)Char has three
types(char,signed char,unsigned char)=1 byte
DECISION
MAKING:
*C language possesses such decision
making capabilities by supporting the following elements:
1)if
statement
1)simple if statement
2)if...else statement
3)Nested if....else statement
4)else if ladder
2)switch statement
3)Conditional statement
4)goto statement
LOOPING:
1)The while statement(Entry Controlled Loop)
2)The do
statement(Exit Controlled Loop)
3)The for statement
(Entry Controlled Loop)
What is
difference between Entry controlled
and Exit Controlled?
*In Entry controlled loop the test condition is checked first
and if the condition is true then the block of sttaement in the loop body will
be executed. While in exit controlled loop the body of loop will be executed
first then check the condition.
ARRAYS:
*An array is a fixed size sequenced collection
of elements of same datatype.
Types of array:
1)One-dimensional arrays (datatype
arr-name[size])
2)Two-dimensional arrays(datatype
arr-name[row-size][col-size])
3)Multi-dimensional
arrays(datatype arr-name[s1][s2][s3]...[sn])
STRING:
*String is a sequence of chars that is treated
as a single data item.
Ways of getting string:
1)scanf("%c",n)
2)ch=getchar()->only
for single word
3)gets(a)
4)c=getc(fp2)
Ways of display string:
1)printf("%c",n)
2)putchar(ch)
3)puts(n)
4)putc(c,fp1)
* fprintf,fscanf handle a
group of mixed data simultaneously.
EX:
fprintf(fp,'control
string',list)
STRING
HANDLING FUNCTIONS:
1)strcat function(str1,str2)
2)strcmp
function(str1,str2)
3)strlen function(str)
FUNCTIONS:
*Function is a sub program that can
perform any particular task.
Two types of functions:
1)library functions or
predefined(printf,strcat)
2)User defined
functions
CATAGORY
OF FUNCTIONS:
1)Functions with no argument and no
return values.
2)Functions with
arguments and no return values.
3)Function with no
argument but return a value.
4)Function that return
multiple values.
1)Automatic variables:
PREPROCESSOR
DIRECTORIES:
STORAGE
CLASS:
*In C all variables have a storage class:They
are
1)Automatic variables(Local or internal
variables)
2)External
variables(Global)
3)Static variables()
4)Register
variables
*These are declared
inside the function. They are created when the function is called and destroyed
automatically when the function is executed.
2)External variables:
*Variables that
are both alive and active throughout the
entire program is external variables.
EX: extern
int a=5;
3)Static
variable:
*The value of static
variables persists until the end of the
program.
EX: static
int count=5;
4)Register
variable:
*In register variable,
variables are stored in one of the machine register. Because the register
access is much faster than a memory access.
EX: register
int count;
STRUCTURE:
*It is a collection of data items of different types using a single name.
UNION:
*Union is similar to structure.
The distinction between them in terms
of storage.
*In structure, all member has
its own storage location.
*In union, all member uses the same
location.
POINTER:
What is a pointer and does Java support
pointers?
Pointer is a reference handle to a memory location. Improper
handling of pointers leads to memory leaks and reliability issues hence Java
doesn't support the usage of pointers.
*Pointers contain memory address as their values.
Since these memory addresses are
locations in the computer memory where the data are stored.
Features of pointers:
*pointers reduce length and
complexity of programs.
*They increase the execution speed and thus they reduce the
program execution time.
Disadvantages:
* By using pointer the hacker
can get the address of source code and can change them.
*EX const int x=5;
*In the above ex the value of x
can't be change.But using pointer it is possible.
FILE:
*A file is a place on the disk where a group of related
data is stored.
*The basic file operations are
1)Naming a file
2)Opening a file
3)Reading data from a file
4)Writing data to a file.
5)Closing a file
1)Naming and opening a file and closing a
file:
*FILE *fp;
fp=fopen('filename','mode');
mode->specifies
the purpose of file opening.
r=open the file reading only
w=open the file for writing only
a=open the file to adding data to
it.
To close a
file:
*fclose(file pointer);
MEMORY
ALLOCATON FUNCTIONS:
*malloc()
*malloc()
*calloc(allocating space
for arrays)
*free(frees previously
allocated space)
*realloc(modofies the size
of previously allocated space)
*#define
*#undef *#ifndef
*#Include *#if
*#ifdef *#else
No comments:
Post a Comment
Your comments and suggestions will help me to serve you better.