S1S2 Syllabus - Btech - Kannur University

Curricula, Scheme of Examinations & Syllabus for
COMBINED I & II SEMESTERS
of B.Tech. Degree Programme
with effect from 2007 Admissions
KANNUR UNIVERSITY
FACULTY OF ENGINEERING
2K6 EN101: ENGINEERING MATHEMATICS I
2 hours lecture and 1 hour tutorial per week
Module I: Ordinary Differential Equations (16 hours)
A brief review of the method of solutions first order equations – Separable , homogeneous and linear
types – Exact equations – Orthogonal trajectories – General linear second order equations- homogeneous linear
equation of the second order with constant coefficients- Fundamental system of solutions – Method of variation
of parameters – Cauchy's equation.

Module II: Laplace Transforms (17 hours)
Gamma and Beta functions – Definition and simple properties – Laplace transform – Inverse transform –
Laplace transform of derivatives and integrals – Shifting theorems – Differentiation and integration of
transforms – Transforms of unit step function and impulse function – Transforms of periodic functions –
Solutions of ordinary differential equations using Laplace transforms.

Module III: Vector differential calculus (18 hours)
Functions of more than one variable – Idea of partial differentiation – Euler's theorem for homogeneous
functions – Chain rule of partial differentiation – application in errors and approximations. Vector function of
single variable - differentiation of vector functions Scalar and vector fields – Gradient of a scalar field –
Divergence and curl of vector fields – Their physical meanings – Relation between the vector differential
operators.

Module IV: Fourier series and harmonic analysis (15 hours)
Periodic functions – Trigonometric series – Euler formulae – Even and odd functions – Functions having
arbitrary period – Half range expansions – Numerical method for determining Fourier coefficients – Harmonic
analysis.

Reference Books:
1. Piskunov N, Differential and Integral calculus, MIR Publishers
2. Wylie C R & Barrett L. C., Advanced Engineering Mathematics, Mc Graw Hill
3. Grewal B. S, Higher Engineering Mathematics, Khanna Publishers
4. Kreyszig E., Advanced Engineering Mathematics, Wiley Eastern.
5. Thomas G B , Calculus and Analytic Geometry, Addison Wesley
6. Spigel. , Vector analysis, Schume series, Mc Grawhill
7. Sastri. S. S. Engineering Mathematics, Prentice Hall of India.

Sessional work assessment 
Assignments           2x10                 = 15
2 tests                     2x15                 = 30
Attendance                                       = 5
Total marks                                     = 50

University Examination Pattern
Q I - 8 short type questions of 5 marks, 2 from each module.
Q II - 2 questions A and B of 15 marks from module I with choice to answer any one.
Q III - 2 questions A and B of 15 marks from module II with choice to answer any one.
Q IV - 2 questions A and B of 15 marks from module III with choice to answer any one.
Q V - 2 questions A and B of 15 marks from module IV with choice to answer any one.

2K6 EN102: ENGINEERING PHYSICS
2 hours lecture per week
Module I: (11 hours)
Interference of light : Interference from plane parallel thin films – Colours of thin films by reflected light - Newton's
rings - Measurement of wave length – Thin wedge shaped air film – Air wedge – Testing of optical planes of surfaces.
Diffraction of light : Introduction to Fresnel and Fraunhofer diffraction – Distinction between the two diffractions –
Simple theory of plane transmission grating.
Polarization of light : Double refraction – Nicol prism – Quarter and half wave plates – Production and detection of
elliptically and circularly polarized light – Rotatory polarization – Laurent's half shade polarimeter – Applications of
polarized light.

Module II: (11hours)
Quantum Mechanics: Newtonian Mechanics and quantum mechanics – Uncertainty principle – The wave functions
– Shrodinger wave equation for free particle – Potentials in Shrodinger equation – Time independent Shrodinger
equation - Time dependent Shrodinger equation – Expectation values – Derivation of Shrodinger equation –
Application – Particle in a box (motion in one dimension ).
NMR and ESR : Basic principles of Nuclear Magnetic Resonance (NMR) and Electron Spin Resonance (ESR) –
Experimental Method for detection of NMR and ESR – Applications.

Module III: (11 hours)
Laser Physics: Basic concepts of laser – Spontaneous and stimulated emission – Absorption – Population inversion –
Optical pumping – Construction and components of laser – Ruby laser, Helium-Neon Laser and semiconductor laser –
Applications – Basic principle of Holography and its application.
Fibre Optics : Basic principles – Fiber construction – Fiber dimensions – Light propagation in fiber – Signal
distortion in optical fibers and transmission losses (Brief ideas only) – Light Wave communication using optical fibers
and its advantages – Fiber Amplifiers and EDFAs – Applications of optical fibers.
Non Destructive Testing : X-rays – Properties and production – X-ray radiography – Stereo Radiography – CT scan –
Ultrasonics – properties – NDT using ultrasonics – Electrical method – Magnetic method – Ultrasound scanning- MRI
scan.

Module IV: (13 hours)
Electron Theory of Solids : Classical free electron theory – drift velocity – conductivity – relaxation time – mean
free path – temperature dependence of resistivity – relation between thermal and electrical conductivities (Weidman –
Frenz law) – Quantum free electron theory – density of states – Fermi distribution function – Fermi energy-Band
theory of solids (Qualitative only ) - Band structure of metals, semiconductors and insulators – Classifications of
semiconductors on the basis of Fermi level and Fermi energy – Impurity levels in N-type and P-type semiconductors.
Hall effect : Introduction – Measurement of Hall voltage and Hall coefficient – Importance of Hall effect.
Super conductivity : Properties of superconductors – Josephson effect and tunneling (qualitative) – B.C.S Theory of
superconductivity (qualitative) – Applications of superconductivity

Reference Books:
1. Brijlal & Subrahmanyam. N, “Text Book of Optics”, S. Chand
2. Rajendran and Marikani : Applied Physics for Engineers 3 rd edition -TMH
3. A.S.Vasudeva S “Modern Engineering Physics” , S. Chand
4. Jenkins F.A & White H.E. “Fundamentals of Optics”, Mc Graw Hill.
5. M. Arumugam : Material science: Anuradha Publications
6. S.O. Pillai “Solid State Physics” New Age International
7. Srivastva . C.M & Sreenivasan. C. “Science Engineering Materials”, New Age International

Sessional work assessment 
Assignments           2x10                 = 15
2 tests                     2x15                 = 30
Attendance                                       = 5
Total marks                                     = 50

University Examination Pattern
Q I - 8 short type questions of 5 marks, 2 from each module.
Q II - 2 questions A and B of 15 marks from module I with choice to answer any one.
Q III - 2 questions A and B of 15 marks from module II with choice to answer any one.
Q IV - 2 questions A and B of 15 marks from module III with choice to answer any one.
Q V - 2 questions A and B of 15 marks from module IV with choice to answer any one.

2K6 EN 103: ENGINEERING CHEMISTRY
2 hours lecture per week
Module I: High Ploymers & Lubricants (13 hours)
Classification of polymers. Polymerization – chain polymerization, condensation polymerization, copolymerization,
coordination polymerization, electrochemical polymerization, metathetical polymerization, group transfer polymerization.
Mechanism of polymerization. Polymerization technique- bulk polymerization, solution polymerization, suspension
polymerization,emulsion polymerization,melt polymerization, solution polycondensation, interfacial condensation, solid and
gas phase condensation, Structure- property relationship of polymers. Compounding and moulding of polymers.
Important plastics – their production,properties and uses. Thermoplastic resins (PE,PP,PVC,PVA,PMMA,PS), thermosetting
resins (Bakelite, Urea formaldehyde, Silicones), fibers(nylon 6, nylon 66, cellulose fibers, Dacron, Kevlar)
Elastomers – Natural rubber – production,structure, properties, compounding & vulcanization. Synthetic rubbers- (Buna,
neoprene, thiokols, polyurethane,silicon rubber)
Lubricants: Theory of friction, mechanism of lubrication, classification of lubricants- liquid,semi solid, solid and synthetic
lubricants. Properties of lubricants. (viscosity index, cloud point, pour point, flash point, fire point, corrosion stability,
emulsification, aniline point). Additives and their functions.

Module II: Electrochemistry (11hours)
Electrode potential and electromotive force.Nernst equation for electrode potential. Measurement of EMF and electrode
potential. Types of electrodes. Primary and secondary reference electrodes. Electrochemical series. Galvanic cells and
concentration cells. Determination of pH using glass electrode.
Secondary cells- lead acid cells,Ni-Cd cell, Edisson cell. Fuel cell- Hydrogen-oxygen fuel cell. Acid and bases. Lowry-
Bronsted and Lewis concepts. Concept of pH- pH measurements.(instrumental details required) Dissociation constants-
potentiometric titrations. Buffer solutions. Henderson equation for calculation of pH.

Module III: Corrosion(11 hours)
Corrosion and its control- Theories of corrosion. Different types of corrosion. Factors affecting corrosion. Protective
coatings. Self protecting corrosion products. Pretreatment of surfaces.
Coating- organic,inorganic coatings- galvanizing, tinning, electroplating, electroless plating, anodisation, passivation by
chemical treatment, cathodic protection.
Properties and functions of ingredients in paints, varnishes and enamels.

Module IV: Fuels & Environmental Pollution(13 hours)
Classification of fuels- solids, liquid & gaseous fuels, Determination of calorific value.
Solid fuels- wood, peat, lignite, coal, Proximate analysis, Petroleum and its refining, fractions and their uses. Cracking and
reforming. Petrol knock and octane number.
Gaseous fuels- Natural gas, coal gas, acetylene. Combustion calculation. Air-fuel ratio.
Pollution- Classification (global, regional and local with examples). Air pollution- Primary and secondary pollutants.
Source, effects and control of air pollution.
Water pollution- Pollutant classification- organic, inorganic, suspended, metals and their monitoring. Domestic sewage and
industrial wastes. Control of water pollution. Hazardous wastes. Hard and soft water. Analysis of hardness. Quality of water
for domestic use and boiler feed. Problem with hard water in boilers. Softening of water – internal and external conditioning
of water.

Reference Books:
1. V. Raghavan(2000) Material Science and Engineering – A first course, Prentice Hall of India Pvt. Ltd. New Delhi.
2. J.C. Kuriakose & J.Rajaram. Chemistry of Engineering & Technology. Vol. I&II Tata McGraw Hill, New Delhi
3. A.K. De(1996) Environmental Chemistry. NewAge Intrnational Pvt. Ltd. New Delhi.
4. B.R Gowariker etal (2000) polymer science. New Age international Pvt. Ltd. New Delhi
5. S. Glasstone (1997) Textbbok of physical Chemistry. MacMillian, NewDelhi.
6. Shashi chawla A text book of Engineering Chemistry. Dhanpath Rai & Co. Pvt. Ltd. NewDelhi


Sessional work assessment 
Assignments           2x10                 = 15
2 tests                     2x15                 = 30
Attendance                                       = 5
Total marks                                     = 50

University Examination Pattern
Q I - 8 short type questions of 5 marks, 2 from each module.
Q II - 2 questions A and B of 15 marks from module I with choice to answer any one.
Q III - 2 questions A and B of 15 marks from module II with choice to answer any one.
Q IV - 2 questions A and B of 15 marks from module III with choice to answer any one.
Q V - 2 questions A and B of 15 marks from module IV with choice to answer any one.

2K6 EN104: ENGINEERING MECHANICS
2 hours lecture and 1 hour tutorial per week
Module I: (15 hours)
Principles of statics – Free body diagrams – coplanar forces and force systems – Resultant and
equilibrium conditions for concurrent,parallel and general system of forces – Solution of problems by scalar
approach. Introduction to vector approach (Application to simple problems only) – Concurrent forces in space –
Resultant – Equilibrium of a particle in space – Non-concurrent forces in space – Resultant of force systems.

Module II: (17hours)
Friction – Laws of friction – Simple contact friction problems – Wedge. Properties of surfaces – First
moment and centroid of curve and area – Centroid of composite plane figures – Theorems of Pappus – guldinus
– Second moments of plane figures and composite sections – Transfer theorems – Polar moment of area –
Product of inertia and principal axes. Moment of inertia of a rigid body – M I of a lamina – M.I of 3 dimensional
bodies (cylinder, circular rod, sphere).

Module III: (17 hours)
Introduction to structural mechanics – Different types of supports, loads and beams – Reactions at
supports. Shear force and Bending moment in beams - Shear force and Bending moment diagrams for cantilever
and simply supported beams (only for concentrated and uniformly distributed load cases). Plane trusses – Types
of trusses (Perfect, Deficient and Redundant trusses) – Analysis of trusses – Method of joints – Method of
sections.

Module IV: (17 hours)
Kinetics of rectilinear motion – Newton's second law – D'Alembert's principle – Motion in horizontal
and inclined surfaces- Analysis of lift motion – Motion of connected bodies. Curvilinear motion – Equation of
motion – Tangential and normal acceleration – Centripetal and centrifugal forces – Motion of vehicles on
circular path . Work, power and energy – Work done by a force – Work of the force of gravity and force of spring
– Work-energy equation – Transformation and conservation of energy- Applications to problems. Kinematics of
rotation – Rigid body rotation about a fixed axis – Rotation under the action of constant moment. Introduction to
mechanical vibrations – Simple harmonic motion – free vibration – Oscillation of spring – Torsional vibration.

Text Books:
1. Timoshenko and Young, “Engineering Mechanics”, McGraw Hill Publishers
2. Hibbler, Engineering Mechanics, Vol I statics, Vol II Dynamics, Pearson
Reference Books:
1. Beer,F.P. Amd Johnson, E.R.,”Mechanics for Engineers- Statics and Dynamics”, McGraw Hill
2. Shames, I.H.,”Engineering Mechanics- Statics and Dynamics”, Prentice Hall of India
3. Merriam J.L and Kraige L.G., Engineering Mechanics- vol 1 and 2, John Wiley
 
Sessional work assessment 
Assignments           2x10                 = 15
2 tests                     2x15                 = 30
Attendance                                       = 5
Total marks                                     = 50

University Examination Pattern
Q I - 8 short type questions of 5 marks, 2 from each module.
Q II - 2 questions A and B of 15 marks from module I with choice to answer any one.
Q III - 2 questions A and B of 15 marks from module II with choice to answer any one.
Q IV - 2 questions A and B of 15 marks from module III with choice to answer any one.
Q V - 2 questions A and B of 15 marks from module IV with choice to answer any one.

2K6 EN105: ENGINEERING GRAPHICS
1 hours lecture and 3 hours drawing practice
Module 0: (12 hours – 2 drawing exercises) (No questions in the university exam: Questions should be
included in the class test)
Introduction to engineering graphics- drawing instruments and their uses – types of lines – lettering –
dimensioning – BIS code for practice for engineering drawing – construction of conics, spirals, cycloids,
involutes and helix.

Module I: (14 hours – 2 drawing exercises)
Introduction to orthographic projection. Projection of points – projection of lines – parallel to one plane and
inclined to the other- lines inclined to both the planes – true length and inclination with reference planes – traces.
Trapezoidal and rotating line method. Projections of planes.

Module II: (14 hours – 2 drawing exercises)
Orthographic projection of solids in simple position-projections of frustum and truncated solids- projection of
solids with axis inclined to one or both the planes- projections on auxiliary planes- primary and secondary
auxiliary projections- projections of solids in combination.

Module III: (18 hours – 3 drawing exercises)
Sections of solids by horizontal, vertical or inclined planes- true shape of section. Development of surface of
solids, sectional solids, solids having hole.
Intersection of surfaces- intersection of prism in prism, cylinder in cylinder and cylinder in cone.

Module IV: (12 hours – 2 drawing exercises)
Introduction to isometric projection- isometric scale – isometric
view- isometric projections of solids, frustums & truncated solids and their combinations.
Conversion of pictorial projection to orthographic projection.

Module IV: (16 hours – 3 drawing exercises)
Introduction to machine drawing- screwed fastening- bolts and nuts-cap screw-machine screw-set screw-locking
arrangements-foundation bolts. Graphic symbols used in engineering. Simple and Sectional views of Knuckle
joint-protected type flanged coupling, bushed bearing-socket and spigot pipe joint.
Note: All drawing exercises mentioned above are for class work. Additional exercises whenever necessary may
be given as home assignments.

Reference Books:
1. John K C,Engineering Graphics, JET Publishers
2. Varghese P I, Engineering Graphics, VIP Publishers
3. Bhatt N D, Elementary Engineering Drawing, Charotar Publishing House
4. Narayana K L & Kannaiah P, Engineering Graphics, Tata McGraw Hill
5. Luzadder W J, Fundamentals of Engineering Drawing, Prentice Hall of India
6. K Venugopal, Engineering Graphics, New Age International (P) Ltd
7. K N Anilkumar,Engineering Graphics, Adhyuth Publishers Kottayam
8. Varghese P I, Machine Drawing, VIP Publishers
9. Bhatt N D, Machine Drawing, Charotar Publishing House
10. S.B.Mathur, A Text Book of Engineering Graphics, Vikas Publishing house

Sessional work assessment
Drawing Exercises          = 20
Class tests(min:2)           = 25
Attendance                      = 5
Total marks                    = 50

University Examination Pattern (Each questions carries 20 marks)
Q I - 2 questions from module I with choice to answer any one.
Q II - 2 questions from module II with choice to answer any one.
Q III - 2 questions from module III with choice to answer any one.
Q IV - 2 questions from module IV with choice to answer any one.
Q V - 2 questions from module V with choice to answer any one.

2K6 EN106: BASIC CIVIL ENGINEERING
2 hours lecture and 1 hour tutorial per week

Module I: (16 hours)
Measurement of distance- Direct measurement – tape & chain only- Ranging out survey lines- Taking
measurement of a sloping ground – Errors – Tape correction problems.
Levelling instruments (Dumpy level, Tilting level and Auto levels ).Levelling Staff (folding type only)- How to
make measurements- temporary adjustment- holding the staff,reading the staff, principles of levelling - recording
measurements in the field book- deduction of level- height of collimation method only, examples.
Introduction to total station(description only)- linear and angular measurements using total station, Brief
description of contour maps.

Module II: (14hours)
Selection of site for buildings- types of buildings- Components of buildings.
Exposure to various building byelaws.
Fire resistance characteristics of buildings- General classification as per National Building Code
Earth quake zoning – disaster mitigation methods.

Module III: (18 hours)
FOUNDATION: different types(description only) .Spread footing, Isolated Footing, Combined Footing-
Mat foundation- Pile foundation. Safe bearing capacity of soil, importance of the safe bearing capacity of soil.
SUPER STRUCTURE: Masonry-stone masonry,brick masonry.
Partition-Materials used for the construction of doors and windows- wood, Steel, Aluminium.
Flooring- using mosaic, ceramic tiles, marble, granite and synthetic materials.
Roofing- Selection of type of roof, sloping roof- Concrete roof, tiled roof, timber roof, GI sheet, AC sheet, PVC
Sheet. Selection of roof covering materials.

Module IV: (17 hours)
CONCRETE: Ingredients- cements,aggregates and water. Qualities of ingredients.
Test for determining the qualities of fine aggregate- fineness modules and grading curves. IS Specifications,
Cement – mortar- IS Specification for preparation and determination of mortar strength. Plain Cement
Concrete(PCC) preparation- Test on Hardened Concrete. IS specification for the compressive strength of
concrete.
Steel- common types used in construction – Mild steel, HYSD steel and their properties.
Reinforced Cement Concrete (RCC)- advantages of RCC over PCC. Elementary ideas on pre-cast and pre-
stressed concrete constructions.

Reference Books:
1. T.P. Kenetker & S.V Kulkarny, “Surveying & Levelling Vol: 1”, Vidyarthi Griha prakashen
2. Rangwala, “Building Materials”, Charotar Publishing House
3. Rangwala, “Building Construction”, Charotar Publishing House
4. B.C Punmia, “Building Materials”, Lakshmi Publication (p) Ltd.
5. S.K.Roy, “Fundamentals of Surveying” Prentice -Hall of India, New Delhi
6. National Building Code
7. A.M Chandra, “Higher Surveying”, New Age International (p) Ltd. Publishers.

Sessional work assessment 
Assignments           2x10                 = 15
2 tests                     2x15                 = 30
Attendance                                       = 5
Total marks                                     = 50

University Examination Pattern
Q I - 8 short type questions of 5 marks, 2 from each module.
Q II - 2 questions A and B of 15 marks from module I with choice to answer any one.
Q III - 2 questions A and B of 15 marks from module II with choice to answer any one.
Q IV - 2 questions A and B of 15 marks from module III with choice to answer any one.
Q V - 2 questions A and B of 15 marks from module IV with choice to answer any one.

2K6 EN107: BASIC MECHANICAL ENGINEERING
2 hours lecture and 1 hour tutorial per week
Module I: (18 hours)
Thermodynamics: Definitions and basic concepts- systems, properties, state, process and cycle- work
and heat- thermodynamic equilibrium, Zeroth law of thermodynamics, concepts of temperature and temperature
scales, first law of thermodynamics, concepts of internal energy and enthalpy,second law of thermodynamics-
Clausius and Kelvin-Planck statements, concept of entropy, thermodynamic processes- constant volume,
constant pressure, adiabatic, isentropic, polytropic processes- P-V and T-S diagrams. (Simple problems only).

Module II: (18 hours)
air cycles: Carnot, Otto and Diesel cycles- air standard efficiency.( Simple problems only)
I C Engines: Working and comparison of two stroke and four stroke petrol and diesel engines.
Pumps and Turbines: Working principles of reciprocating, centrifugal and rotary pumps. Principles of operation
of Pelton, Francis and Kaplan turbines. (Elementary ideas with simple sketches only).

Module III: (18 hours)
Properties of steam- saturation temperature, dryness fraction, degree of superheat, specific volume,
enthalpy and entropy0 T-S diagram.
Steam Boilers: Classification- Cochran boiler, Babcock and Wilcox boiler, list of boiler mountings and
accessories- applications.
Refrigeration and Air conditioning: Refrigerants, properties of refrigerants, working principles of vapour
compression refrigeration & vapour absorption refrigeration systems. Psychrometry- definitions of terms-
Principles of air conditioning – comfort and industrial air conditioning.

Module IV: (17 hours)
Classification of manufacturing processes- elementary ideas with simple sketches of moulding, sand casting, die
casting, forging, rolling, extrusion, wire drawing, punching and blanking, stamping, coining, surfacing, welding,
soldering, and brazing.
Production machines- elementary ideas with simple sketches of centre lathe, milling machine, drilling machine,
grinding machine and shaper. basic machine operations- Concepts of CNC machine systems.

Text Books:
1. S. Tryambaka Murthy, Elements of Mechanical Engineering, Vikas Publishing House Private Ltd.
2. S. Benjamin, A Text Book of Basic Mechanical Engineering, Pentex Publishers and Distributers,
Kollam-5

Reference Books:
1. S. K. Hajra Choudhury, Elements of Mechanical Engineering, Media Promoters and Publishers Pvt.
Ltd. Mumbai
2. P. K.Nag, Engineering Thermodynamics, Tata McGraw Hill Publishing Company
3. Dr. R.K. Bansal, Fluid Mechanics and Hydraulic machines, Laxmi Publications (P) Ltd., New Delhi
4. M.L. Mathur and F.S. Meha, Thermal Engineering, Jain Brothers, New Delhi
5. K .Venugopal, Basic Mechanical Engineering, New Age International (p) Ltd.


Sessional work assessment 
Assignments           2x10                 = 15
2 tests                     2x15                 = 30
Attendance                                       = 5
Total marks                                     = 50

University Examination Pattern
Q I - 8 short type questions of 5 marks, 2 from each module.
Q II - 2 questions A and B of 15 marks from module I with choice to answer any one.
Q III - 2 questions A and B of 15 marks from module II with choice to answer any one.
Q IV - 2 questions A and B of 15 marks from module III with choice to answer any one.
Q V - 2 questions A and B of 15 marks from module IV with choice to answer any one.

2K6 EN108: BASIC ELECTRICAL ENGINEERING
2 hours lecture and 1 hour tutorial per week
Module I: (16 hours) Generation, Transmission and Distribution of 
electric power
Conventional methods of generation of electric power- thermal- hydro- nuclear. Non-conventional energy
sources- solar-wind-tidal-geothermal-photovoltaic-fuel cells. General outline of power transmission &
distribution system- substation equipment- circuit breakers- isolators, lightning arrestors- wave traps-(Functions
only)
Electrical wiring- different types- switchboards- earthing- protective devices- relays- MCB's, ELCB's

Module II: (17 hours) Transformers and Electrical machines
AC Fundamentals- 1-Ö and 3-Ö- Power factor- economics of power factor improvement.(Derivation not
required)
Tariff- Types of Tariff.
Transformers- Construction- different types-1-Ö and 3-Ö- theory- emf equation-methods of cooling.
DC Machines- Construction- generators and motors- types – characteristics & applications.
AC Machines- Alternators- Construction- voltage regulation (definition only). Synchronous motors-
Applications.
Induction motors- 1-Ö and 3-Ö- construction- characteristics & applications
Special machines- stepper motor- universal motor.

Module III: (17 hours) Utilization of Electric Power
Electric heating- resistance heating-Induction heating-dielectric heating-arc furnaces-principle & applications.
Electric welding-resistance welding-arc welding-ultrasonic welding-electron beam welding- laser beam welding.
Illumination- different types of lamps- fluorescent, incandescent, sodium vapor, mercury vapour, halogen-
energy efficient lamps.
Traction- traction equipment and functions.
Batteries- different types- Charging methods- Applications.
Electrolytes- Basic principles- Extraction of metals- Electro deposition- Electroplating.

Module IV: (16 hours) Instrumentation
Measuring instruments-Ammeter, voltmeter, Wattmeter, Energy meter, Meggar- basic principle of operation,
measurement of power by 2- wattmeter method..
Transducers- measurement of strain, acceleration, altitude, flow, torque, humidity and moisture.

Text Books:
1. Jain & Jain, “ABC of Electrical Engineering (Electrical Science)”, Dhanpat Rai & Son's publishing
company, New Delhi

Reference Books:
1.M.L. Soni, P V Gupta, U.S> Bhatnagar and A. Chakrabarthy- A Textbook of Power System
Engineering- Dhanpat Rai & Son's, New Delhi
2. Nagarath I.J. & Kothari D.P.- Electric Machines- Tata McGraw Hill
3. J.B. Gupta- Utilization of electric power & Electric traction – S.K. Kataria & Sons, New Delhi
4. Sawhney A.K. A Course in Electrical & Electronic Measurement and Instrumentation, Dhanpat Rai
& Son's, New Delhi

Sessional work assessment 
Assignments           2x10                 = 15
2 tests                     2x15                 = 30
Attendance                                       = 5
Total marks                                     = 50

University Examination Pattern
Q I - 8 short type questions of 5 marks, 2 from each module.
Q II - 2 questions A and B of 15 marks from module I with choice to answer any one.
Q III - 2 questions A and B of 15 marks from module II with choice to answer any one.
Q IV - 2 questions A and B of 15 marks from module III with choice to answer any one.
Q V - 2 questions A and B of 15 marks from module IV with choice to answer any one.


2K6 EN109: BASIC ELECTRONICS AND COMPUTER ENGINEERING
2 hours lecture and 1 hour tutorial per week
PART A- ELECTRONICS & COMMUNICATION ENGINEERING
Module I: (16 hours) Introduction To Electronic Components & Devices
Electronic Devices: Passive components, Active components. PN Junction Diodes: Characteristics and
applications. Types of Diodes: Zener Diode, LED, LCD, Photodiode, varactor diode- principles of operation and
applications. Bipolar Junction Transistors- construction- npn, pnp- working- configuration-characterestics-
properties-applications.Amplifiers: RC Coupled amplifier – working. JFET: construction-characterestics,
parameters- applications. Oscillators: principle, RC Phase shift oscillator, crystal oscillator. Integrated circuits:
classification-advantages-analog and digital ICs. Microprocessors-8085: Internal architecture(block diagrams
only)-applications. Electronic Instruments: Strain gauge, Thermistor, condensor microphone, Moving coil Loud-
speaker, principles of CRT,CRO block diagram and working. Signal generators, regulated powersupplies.
Module II: (17 hours) Principles of Electronic Communication Engineering
Analog modulation- Different types-AM,FM,PM-principles and comparison. Block diagram of AM and FM
Transmitters and superhetrodyne receiver (brief explanation only). Principle of TV systems: interlaced scanning,
general simplified block diagram of TV Transmitter and receiver, Yagi antenna, Basic principles of cable TV.
Principles of pulsed RADAR: Block diagram, application. Satellite communication- Concept of Geostationary
satellites- simplified block diagram of earth station, Transmitter, Receiver. Blockdiagram of optical
communication systems, Concept of optical fibre, source(LED), detector (phototransistor), advantage of optical
communication.
Frequency bands in microwave communication and their uses, simplified block diagram of microwave link.
Basic principle of cellular communication, concepts of cells- Frequency reusage, advantage of cellular
communication.
PART B- COMPUTER ENGINEERING
Module III: (16 hours) Introduction to Computers, Troubleshooting & Maintenance
Introduction- Characteristics of computers- Classifications of Computers- Basic computer organizations-
Computer software- Types of software. Components of Standard PC: Familiarization of motherboard, Processor
& Memory, Graphics adapters & Monitors, Drive controllers & Drives, Buses, Network adapters, Power supply-
Boot process: BIOS,POST- Installation of operating systems- Troubleshooting and Maintenance : common
problems in Motherboard, Memory, Monitor, Plug&Play Devices and their Troubleshooting.

Module IV: (17 hours) Computer Programming & Network Fundamentals
Computer programming- High level and low level languages- steps involved in computer programming-
Developing algorithms and flowcharts- Efficiency of algorithms- Running, debugging and testing of programs.
Computer Network: Topologies- Types, Basic components, Media: Wireless & wired. Internet Basics:
Applications & impact on Society. WWW, Email, Search Engine, Webserver, Web browser- Future Internet
applications. Application software packages- Word processing-Spread sheet- Graphics-Personal Assistance

Reference Books:
1. N.N. Bhargava. “Basic Electronic and Linear Circuits” TMH Publications
2. A Kumar. “Communication Engineering” mesh publication New Delhi
3. Peter Norton, ”Introduction to Computer”, 6 th Ed., Tata McGraw Hill, 2006
4. Pradeep K Sinha and Priti Sinha, “Computer Fundamentals: Concepts, Systems and Application”, BPB Publications,
2003.
5. T F Bogart, “Electronic Devices ans Circuits” Universal Bookstall New Delhi
6. Santi ram Kal. “Basic Electronics” PHI Publications.
7. George Kennedy, “Electronic Communication Systems”, McGraw Hill
8. V. Rajaraman, “Fundamentals of Computers” Prentice Hall of India, 2002
9. Hans-Peter Messmer, “The Indispensable PC hardware book” 3 rd Ed., Addison Wesely
10. Allen B. Tucker, “Fundamentals of Computing”, Tata McGraw Hill, New Delhi, 1998
11. Stephen J Bigelow “Troubleshooting Maintaining & Repairing PCs”, 5 th Ed., Tata McGraw Hill
12. Andrew S Tanenbaum, “Computer Network”, 3 rd Ed., Pearson Education, 2003

Sessional work assessment 
Assignments           2x10                 = 15
2 tests                     2x15                 = 30
Attendance                                       = 5
Total marks                                     = 50

University Examination Pattern
(Part A and Part B to be answered in separate answer books)
Part A
Q I - 4 short type questions of 5 marks, 2 from each module.
Q II - 2 questions A and B of 15 marks from module I with choice to answer any one.
Q III - 2 questions A and B of 15 marks from module II with choice to answer any one.
Part-B
Q IV - 4 short type questions of 5 marks, 2 from each module.
Q V - 2 questions A and B of 15 marks from module III with choice to answer any one.
Q VI - 2 questions A and B of 15 marks from module IV with choice to answer any one.

2K6 EN110 P: BASIC ENGINEERING LABORATORY
2 hours practical per week
Part A- Mechanical Engineering workshops
Fitting Practice (10 Hours)
Study of metal cutting and measuring tools.
Fabrication Exercises involving cutting and chiseling
Welding (5 Hours)
Study of arc and gas welding equipments. Exercises involving preparation of lap and butt joints.
Carpentry (10 Hours)
Wood and its processing- measuring and marking tools. Wood working hand tools- Wood working
machinery. Preparation of joints like dove tail, mortise & tenon.
Sheet metal practice (5 Hours)
Study of machines and tools used in sheet metal work.
Development and fabrication of simple sheet metal components like cylindrical dish, rectangular duct.
Foundry (5 Hours)
Study of foundry tool appliances. Preparation of sand molding, making green sand molds for simple
objects. Demonstration of melting, pouring and production of casting.
Smithy (5 Hours)
Study of hand forging tools.
Hand forging exercises to make components of simple Geometry.

Part-B- Civil Engineering Workshop
Surveying (10 Hours )
Chain survey- Traversing and plotting of etails. Plane Table Surveying- method of radiation, inter
section and traversing.
Levelling- Fly leveling.

Sessional Requirements
Total Attendance                      : 5 marks
Part-A Mechanical Engineering Workshops
Workshop Practical and Record            : 25 marks
Test                                                     : 10 marks
Part-B Civil Engineering Workshop
Workshop Practical and Record         : 5 marks
Test                                                 : 5 marks
Total                                                : 50 marks

 2K6 EN111 P: BASIC ELECTRICAL AND ELECTRONICS WORKSHOP
2 hours practical per week
A. Electrical Wiring (total 15 Hours)
a. Familiarization of various types of service mains- wiring and installations- accessories and
household electrical appliances.
b. Earthing – measurement of earth resistances- testing of Electrical installations- precautions and care
from Electrical shocks.
c. wiring practices of a circuit to control :
    i) one lamp by SPST switch
   ii) two lamps by SPST switch.
  iii) two lamps in series and parallel
  iv) stair case wiring
d. Familiarization of various parts and assembling of Electrical Motors and wiring practices of
connecting a 3 phase- 1 phase motor with starter.

B. Electronics Workshop (total 15 hours)
1. Familiarization of various Electronic components such as resistors, capacitors, transformers,
inductors, diodes, transistors and IC's.
2. Assembling and soldering practice of a single phase full wave rectifier circuit with capacitor
filter.
3. Assembling and soldering practice of common emitter amplifier circuits.
4. Assembling a timer circuit using IC555, phase shift oscillator using transistor and op-amp and
JK flip-flop using NAND gates on the bread board.

C. Computer Hardware Lab (total 20 hours)
1. Identification of components/ cards – PC assembling from components.
2. Installation of motherboard, processor, memory and child hard disk.
3. Installation of peripherals such as FDD and a CD drive.
4. BIOS setup.
5. Preparation of HDD for installation – formatting partitioning and basics of file system.
6. Installation of different operating systems and managing application software.
7. Troubleshooting of standard PC.

Sessional Requirements:
Total Attendance                 : 5 marks
Workshop Practical and Record  : 10 marks each for A,B and C
Test                            : 5 marks each for A,B and C
Total                          : 50 marks



download pdf


Parser for Switch Statements with If-then and While Statements inside - Compiler Design - Yacc Program

Program:

// Lex file: pars.l


alpha [a-zA-Z]
digit [0-9]

%%

[ \n\t]
if                  return IF;
then             return THEN;
while           return WHILE;
switch         return SWITCH;
case             return CASE;
default         return DEFAULT;
break           return BREAK;
{digit}+       return NUM;
{alpha}({alpha}|{digit})* return ID;
"<="            return LE;
">="            return GE;
"=="            return EQ;
"!="             return NE;
"&&"           return AND;
"||"               return OR;
.                   return yytext[0];

%%

// Yacc file: pars.y

%{
#include<stdio.h>
#include<stdlib.h>
%}

%token ID NUM SWITCH CASE DEFAULT BREAK LE GE EQ NE AND OR IF THEN WHILE
%right '='
%left AND OR
%left '<' '>' LE GE EQ NE
%left '+''-'
%left '*''/'
%right UMINUS
%left '!'

%%

S    :    ST{printf("\nInput accepted.\n");exit(0);};
      ;
ST  :    SWITCH'('ID')''{'B'}'
      ;
B    :    C
      |    C D
      ;
C  :    C C
    |    CASE NUM':'ST1 BREAK';'
    ;
D  :    DEFAULT':'ST1 BREAK';'
    |    DEFAULT':'ST1
    ;
ST1    :    WHILE'('E2')' E';'
    |    IF'('E2')'THEN E';'
    |    ST1 ST1
    |    E';'
    ;
E2    :    E'<'E
    |    E'>'E
    |    E LE E
    |    E GE E
    |    E EQ E
    |    E NE E
    |    E AND E
    |    E OR E
    ;
E    :    ID'='E
    |    E'+'E
    |    E'-'E
    |    E'*'E
    |    E'/'E
    |    E'<'E
    |    E'>'E
    |    E LE E
    |    E GE E
    |    E EQ E
    |    E NE E
    |    E AND E
    |    E OR E
    |    ID
    |    NUM
    ;

%%

#include"lex.yy.c"

main()
{
    printf("\nEnter the expression: ");
    yyparse();
}

Output:

nn@linuxmint ~ $ lex pars.l
nn@linuxmint ~ $ yacc pars.y
conflicts: 5 shift/reduce
nn@linuxmint ~ $ gcc y.tab.c -ll -ly
nn@linuxmint ~ $ ./a.out

Enter the expression: switch(s)
{
case 1:a=b+c;break;
case 2:    if(a<10)
    then a=b*c;
    break;
case 3:    while(a<5)
    b=b+a;
    break;
}

Input accepted.
nn@linuxmint ~ $

Intermediate Code Generator for For Loop - Compiler Design - Yacc Program

Program:

// Lex file: im4.l

alpha [A-Za-z]
digit [0-9]

%%

[\t \n]
for             return FOR;
{digit}+    return NUM;
{alpha}({alpha}|{digit})* return ID;
"<="         return LE;
">="         return GE;
"=="         return EQ;
"!="          return NE;
"||"            return OR;
"&&"         return AND;
.                return yytext[0];

%%

// Yacc file: im4.y

%{
#include <stdio.h>
#include <stdlib.h>
%}
%token ID NUM FOR LE GE EQ NE OR AND
%right "="
%left OR AND
%left '>' '<' LE GE EQ NE
%left '+' '-'
%left '*' '/'
%right UMINUS
%left '!'

%%

S       : FOR '(' E ';'{lab1();} E {lab2();}';' E {lab3();}')' E';'{lab4(); exit(0);}
         ;
E       : V '='{push();} E{codegen_assign();}
         | E '+'{push();} E{codegen();}
         | E '-'{push();} E{codegen();}
         | E '*'{push();} E{codegen();}
         | E '/'{push();} E{codegen();}
         | '(' E ')'
         | '-'{push();} E{codegen_umin();} %prec UMINUS
         | V
         | NUM{push();}
         ;
V       : ID {push();}
         ;

%%

#include "lex.yy.c"
#include<ctype.h>
char st[100][10];
int label[20];
int top=0;
char i_[2]="0";
char temp[2]="t";

int lno=0,ltop=0;
int start=1;

main()
{
    printf("Enter the expression:\n");
    yyparse();
}

push()
{
   strcpy(st[++top],yytext);
}

codegen()
{
    strcpy(temp,"t");
    strcat(temp,i_);
    printf("%s = %s %s %s\n",temp,st[top-2],st[top-1],st[top]);
    top-=2;
    strcpy(st[top],temp);
    i_[0]++;
}

codegen_umin()
{
    strcpy(temp,"t");
    strcat(temp,i_);
    printf("%s = -%s\n",temp,st[top]);
    top--;
    strcpy(st[top],temp);
    i_[0]++;
}

codegen_assign()
{
    printf("%s = %s\n",st[top-2],st[top]);
    top-=2;
}
lab1()
{
    printf("L%d: \n",lno++);
}
lab2()
{
    strcpy(temp,"t");
    strcat(temp,i_);
    printf("%s = not %s\n",temp,st[top]);
    printf("if %s goto L%d\n",temp,lno);
    i_[0]++;
    label[++ltop]=lno;
    lno++;
    printf("goto L%d\n",lno);
    label[++ltop]=lno;
    printf("L%d: \n",++lno);
 }
lab3()
{
    int x;
    x=label[ltop--];
    printf("goto L%d \n",start);
    printf("L%d: \n",x);
   
}

lab4()
{
    int x;
    x=label[ltop--];
    printf("goto L%d \n",lno);   
    printf("L%d: \n",x);
}

Output:
nn@linuxmint ~ $ lex im4.l
nn@linuxmint ~ $ yacc im4.y
conflicts: 4 shift/reduce
nn@linuxmint ~ $ gcc y.tab.c -ll -ly
nn@linuxmint ~ $ ./a.out
Enter the expression:
for(i=0;i=b;i=i+1) a=a+b;
i = 0
L0:
i = b
t0 = not i
if t0 goto L1
goto L2
L3:
t1 = i + 1
i = t1
goto L0
L2:
t2 = a + b
a = t2
goto L3
L1:
nn@linuxmint ~ $

Substring Search & Replacement - UDP - Client Server Program - Network-DBMS Lab - C Program

Program:

// Server : sbs.c

#include<stdio.h>
#include<string.h>
#include<sys/stat.h>
#include<sys/types.h>
#include<sys/socket.h>
#include<netinet/in.h>
#include<arpa/inet.h>
#include<stdlib.h>


main ()
{
    struct sockaddr_in client,server;
    int s,sock,found,sz,ack=0,length=0,i,j,bi1=0;
    char buffer[100],substring[20],newstring[20];
    FILE *ptr,*op;
   
    s=socket(AF_INET,SOCK_DGRAM,0);
    server.sin_family=AF_INET;
    server.sin_port=2000;
    server.sin_addr.s_addr=inet_addr("127.0.0.1");
    sz=sizeof(client);
    bind(s,(struct sockaddr *)&server,sizeof(server));
   
   
   
    recvfrom(s,substring,sizeof(substring),0,(struct sockaddr *)&client,&sz);
    printf("\nSubstring received: %s.",substring);
    recvfrom(s,newstring,sizeof(newstring),0,(struct sockaddr *)&client,&sz);
    printf("\nNewstring received: %s",newstring);
   ptr=fopen("testrecord.txt","r");
    op=fopen("result.txt","w");
    while((buffer[bi1]=getc(ptr))!=EOF)
        {
                   found=0;
                   bi1++;
                   if(buffer[bi1-1]==substring[0])
                   {
                       length=1;
                       for(i=1;i<strlen(substring);i++)
                    {
                        if((buffer[bi1]=getc(ptr))==substring[i])
                        {                           
                            length++;
                            bi1++;
                        }
                        else
                {
                    bi1++;
                    break;
                }
                    }
                    if(length==strlen(substring))
                    {
                        found=1;
                        ack=1;
                        printf("\nSubstring found.");
            }
        }
        if(!found)
        {
            fprintf(op,"%s",buffer);
           
        }
        else
        {
            fprintf(op,"%s",newstring);printf("\nString replaced.");
        }
        bi1=0;bzero(buffer,100);
       
    }
   
    sendto(s,&ack,sizeof(int),0,(struct sockaddr *)&client,sz);

  if(ack)
  {
  remove("testrecord.txt");
  rename("result.txt","testrecord.txt");
         printf("\nSaved Successfully.\n");
 }
 remove("result.txt");

 fclose(ptr);
 fclose(op);
 close(s);
}


// Client: sbc.c

#include<stdio.h>
#include<string.h>
#include<sys/stat.h>
#include<sys/types.h>
#include<sys/socket.h>
#include<netinet/in.h>
#include<arpa/inet.h>
#include<stdlib.h>

main()
{
    struct sockaddr_in client;
    int s,found=0,choice=0,ack=0;;
    char buffer[20],newstring[20],substring[20];
   
   
    s=socket(AF_INET,SOCK_DGRAM,0);
    client.sin_family=AF_INET;
    client.sin_port=2000;
    client.sin_addr.s_addr=inet_addr("127.0.0.1");
   
   
    printf("Enter the substring: ");
    scanf("%s",substring);
    printf("\nNewstring: ");
       scanf("%s",newstring);
    sendto(s,substring,sizeof(substring),0,(struct sockaddr *)&client,sizeof(client));
   sendto(s,newstring,sizeof(newstring),0,(struct sockaddr *)&client,sizeof(client));

 recvfrom(s,&found,sizeof(int),0,NULL,NULL);
    if(found)
    {
        printf("\nSubstring found & replaced.\n");
    }
    else
    {
            printf("\nNot found.\n");

    }
    close(s);

}




// testrecord.txt

i like www.2k8618.blogspot.com.

Output:

Terminal 1: (Server)
nn@linuxmint ~ $ gcc sbs.c -o server
nn@linuxmint ~ $ ./server

Substring received: 2k8618.blogspot.com.
Newstring received: 2k8cse.cu.cc
Substring found.
String replaced.
Saved Successfully.
nn@linuxmint ~ $

Terminal 2: (Client)
nn@linuxmint ~ $ gcc sbc.c -o client
nn@linuxmint ~ $ ./client
Enter the substring: 2k8618.blogspot.com

Newstring: 2k8cse.cu.cc

Substring found & replaced.
nn@linuxmint ~ $

// testrecord.txt

i like www.2k8cse.cu.cc.

Postfix to Infix - Yacc Program - Compiler Design


Program:-"Beta version"-(Partial Output Only)

// Lex file: ptoi.l

DIGIT [0-9]
%%
{DIGIT}+    {yylval=atoi(yytext);return ID;}
[-+*/]            {return yytext[0];}
.                      ;
\n         yyterminate();

// Yacc file: ptoi.y
%{
    #include<stdio.h>
    #include<string.h>
    void push();
    char* top();
    void a1(char* a);
%}

%token ID

%%

S    : E  { printf("= %s \n",top());}
    ;
E    : E E '+' {a1(" + ");}
    | E E '*' {a1(" * ");}
    | E E '-' {a1(" - ");}
    | E E '/' {a1(" / ");}
    | ID    {push();}
    ;

%%
#include"lex.yy.c"

char st[100][10];
int indx=0;

void push()
{
   strcpy(st[indx++],yytext);
}

char* pop()
{
    return st[--indx];
}

char* top()
{
    return st[indx-1];
}
void a1(char* a)
{
    char buffer[20];
    char* c1=pop();
    char* c2=pop();
    bzero(buffer,20);
    strcat(buffer,c2);
    strcat(buffer,a);
    strcat(buffer,c1);
    strcpy(st[indx++],buffer);
}
main()
{
    yyparse();

}

Output:
nn@linuxmint ~ $ lex ptoi.l
nn@linuxmint ~ $ yacc ptoi2.y
nn@linuxmint ~ $ gcc y.tab.c -ll -ly
nn@linuxmint ~ $ ./a.out
2 5 * 3 2 * +
= 2 * 5 + 3 * 2
nn@linuxmint ~ $ ./a.out
2 5 +
= 2 + 5
nn@linuxmint ~ $ ./a.out
2 3 *
= 2 * 3
nn@linuxmint ~ $ ./a.out
2 3 -
= 2 - 3
nn@linuxmint ~ $ ./a.out
2 5 /
= 2 / 5
nn@linuxmint ~ $

Substring Search & Replacement 2 - Client Server Program - TCP - Network-DBMS Lab - C Program

Program:

// Server: sbstrs.c
#include<stdio.h>
#include<string.h>
#include<sys/stat.h>
#include<sys/types.h>
#include<sys/socket.h>
#include<netinet/in.h>
#include<arpa/inet.h>
#include<stdlib.h>


main ()
{
    struct sockaddr_in client,server;
    int s,sock,found,sz,ack=0,length=0,i,j,bi1=0;
    char buffer[100],substring[20],newstring[20];
    FILE *ptr,*op;
   
    s=socket(AF_INET,SOCK_STREAM,0);
    server.sin_family=AF_INET;
    server.sin_port=2000;
    server.sin_addr.s_addr=inet_addr("127.0.0.1");
    sz=sizeof(client);
    bind(s,(struct sockaddr *)&server,sizeof(server));
    listen(s,1);
    sock=accept(s,(struct sockaddr *)&client,&sz);
   
    recv(sock,substring,sizeof(substring),0);
    printf("\nSubstring received: %s.",substring);
    recv(sock,newstring,sizeof(newstring),0);
    printf("\nNewstring received: %s",newstring);
   
    ptr=fopen("testrecord.txt","r");
    op=fopen("result.txt","w");
    while((buffer[bi1]=getc(ptr))!=EOF)
        {
                   found=0;
                   bi1++;
                   if(buffer[bi1-1]==substring[0])
                   {
                       length=1;
                       for(i=1;i<strlen(substring);i++)
                    {
                        if((buffer[bi1]=getc(ptr))==substring[i])
                        {                           
                            length++;
                            bi1++;
                        }
                        else
                {
                    bi1++;
                    break;
                }
                    }
                    if(length==strlen(substring))
                    {
                        found=1;
                        ack=1;
                        printf("\nSubstring found.");
            }
        }
        if(!found)
        {
            fprintf(op,"%s",buffer);
           
        }
        else
        {
            fprintf(op,"%s",newstring);printf("\nString replaced.");
        }
        bi1=0;bzero(buffer,100);
       
    }
   
    send(sock,&ack,sizeof(int),0);
    fclose(ptr);
    fclose(op);
    remove("testrecord.txt");
        rename("result.txt","testrecord.txt");
        remove("result.txt");
        printf("\nSaved Successfully.\n");
    close(sock);
    close(s);
}

// Client: sbstrc.c

#include<stdio.h>
#include<string.h>
#include<sys/stat.h>
#include<sys/types.h>
#include<sys/socket.h>
#include<netinet/in.h>
#include<arpa/inet.h>
#include<stdlib.h>

main()
{
    struct sockaddr_in client;
    int s,found=0,choice=0,ack=0;;
    char buffer[20],string[20],substring[20];
   
   
    s=socket(AF_INET,SOCK_STREAM,0);
    client.sin_family=AF_INET;
    client.sin_port=2000;
    client.sin_addr.s_addr=inet_addr("127.0.0.1");
    connect(s,(struct sockaddr *)&client,sizeof(client));
   
    printf("Enter a string to search in server:");
    scanf("%s",string);
    send(s,&string,sizeof(string),0);
    recv(s,&found,sizeof(int),0);
    if(found)
    {
        printf("\nThe record found.");
    }
    else
    {
            printf("\nNot found...\n");
            exit(0);
    }
   
    printf("\nDo you want to replace it ?\nEnter 1 -> Yes 2 -> No\n");
    scanf("%d",&choice);
    send(s,&choice,sizeof(int),0);
    if(choice)
    {
        printf("\nSubstring: ");
        scanf("%s",substring);
        send(s,&substring,sizeof(substring),0);
        recv(s,&ack,sizeof(int),0);
        if(ack)
        {
                printf("\nSuccess... ");
        }
        else
        {
                printf("\nError... ");
        }
    }
    else
    {
        printf("\nThanks... ");
            exit(0);
    }
    close(s);

}

// testrecord.txt
    2K8CSE
2K861
2K862
2K863
2K864
2K865
2K866
2K867
2K868
2K869
2K8610
2K8611
2K8612
2K8613
2K8614
2K8615
2K8616
2K8617
2K8618
2K8619
2K8620
2K8621
2K8622
2K8623
2K8624
2K8625
2K8626
2K8627
2K8628
2K8629
2K8630
2K8631
2K8632
2K8633
2K8634
2K8635
2K8636
2K8637
2K8638

Output:

Terminal 1: (server)
nn@linuxmint ~ $ gcc sbstrs.c -o server
nn@linuxmint ~ $ ./server

Substring received: 2K8618.
Newstring received: NIDHEESH
Substring found.
String replaced.
Saved Successfully.
nn@linuxmint ~ $

Terminal 2: (Client)
nn@linuxmint ~ $ gcc sbstrc.c -o client
nn@linuxmint ~ $ ./client
Enter the Substring: 2K8618

Enter the Newstring: NIDHEESH

Substring found & Replaced...
nn@linuxmint ~ $

// testrecord.txt

    2K8CSE
2K861
2K862
2K863
2K864
2K865
2K866
2K867
2K868
2K869
2K8610
2K8611
2K8612
2K8613
2K8614
2K8615
2K8616
2K8617
NIDHEESH
2K8619
2K8620
2K8621
2K8622
2K8623
2K8624
2K8625
2K8626
2K8627
2K8628
2K8629
2K8630
2K8631
2K8632
2K8633
2K8634
2K8635
2K8636
2K8637
2K8638

2K8CSE - Generate Index in a FIle - C Program

Program:

// gen.c

#include<stdio.h>

main ()
{

    int i=1;
    FILE *temp;
    temp=fopen("testrecord.txt","w");
    fprintf(temp,"\t2K8CSE\n");
    while(i<39)
    {
        fprintf(temp,"2K86%d\n",i);
        i++;
    }
    fclose(temp);   
}

Output:
nn@linuxmint ~ $ gcc gen.c
nn@linuxmint ~ $ ./a.out
nn@linuxmint ~ $

// testrecord.txt
    2K8CSE
2K861
2K862
2K863
2K864
2K865
2K866
2K867
2K868
2K869
2K8610
2K8611
2K8612
2K8613
2K8614
2K8615
2K8616
2K8617
2K8618
2K8619
2K8620
2K8621
2K8622
2K8623
2K8624
2K8625
2K8626
2K8627
2K8628
2K8629
2K8630
2K8631
2K8632
2K8633
2K8634
2K8635
2K8636
2K8637
2K8638

Substring Search & Replacement 1 - Client Server Program - Network-DBMS Lab - C Program

Program:

// Server: sbstrs1.c

#include<stdio.h>
#include<string.h>
#include<sys/stat.h>
#include<sys/types.h>
#include<sys/socket.h>
#include<netinet/in.h>
#include<arpa/inet.h>
#include<stdlib.h>


main ()
{
    struct sockaddr_in client,server;
    int s,sock,found,sz,ack=0,length=0,i,j,bi2=0,bi1=0;
    char buf1[200],buf2[200],substring[20],newstring[20];
    FILE *ptr,*temp;
   
    s=socket(AF_INET,SOCK_STREAM,0);
    server.sin_family=AF_INET;
    server.sin_port=2000;
    server.sin_addr.s_addr=inet_addr("127.0.0.1");
    sz=sizeof(client);
    bind(s,(struct sockaddr *)&server,sizeof(server));
    listen(s,1);
    sock=accept(s,(struct sockaddr *)&client,&sz);
   
    recv(sock,substring,sizeof(substring),0);
    printf("\nSubstring received: %s.",substring);
    recv(sock,newstring,sizeof(newstring),0);
    printf("\nNewstring received: %s.",newstring);
   
    ptr=fopen("testrecord.txt","r");
    while((buf1[bi1]=getc(ptr))!=EOF)
        {
                   found=0;
                   bi1++;
                   if(buf1[bi1-1]==substring[0])
                   {
                       length=1;
                       for(i=1;i<strlen(substring);i++)
                    {
                        if((buf1[bi1]=getc(ptr))==substring[i])
                        {                           
                            length++;
                            bi1++;
                        }
                        else
                {
                    bi1++;
                    break;
                }
                    }
                    if(length==strlen(substring))
                    {
                        found=1;
                        ack=1;
                        printf("\nSubstring found.");
            }
        }
        if(!found)
        {
            for(i=0;i<bi1;i++)
            {
                buf2[bi2]=buf1[i];
                bi2++;
            }
           
        }
        else
        {
            for(i=0;i<=strlen(newstring)-1;i++)
                    {
                        buf2[bi2]=newstring[i];
                bi2++;
            }
            printf("\nReplaced.\n");
        }
        bi1=0;
    }
    send(sock,&ack,sizeof(int),0);
    fclose(ptr);
    temp=fopen("temp.txt","w");
           fprintf(temp,"%s",buf2);
    fclose(temp);
    remove("testrecord.txt");
        rename("temp.txt","testrecord.txt");
        remove("temp.txt");
    close(sock);
    close(s);
}


// Client: sbstrc.c

#include<stdio.h>
#include<string.h>
#include<sys/stat.h>
#include<sys/types.h>
#include<sys/socket.h>
#include<netinet/in.h>
#include<arpa/inet.h>
#include<stdlib.h>

main()
{
    struct sockaddr_in client;
    int s,found=0,choice=0,ack=0;;
    char buffer[20],substring[20],newstring[20];
   
   
    s=socket(AF_INET,SOCK_STREAM,0);
    client.sin_family=AF_INET;
    client.sin_port=2000;
    client.sin_addr.s_addr=inet_addr("127.0.0.1");
    connect(s,(struct sockaddr *)&client,sizeof(client));
   
    printf("Enter the Substring: ");
    scanf("%s",substring);
    printf("\nEnter the Newstring: ");
    scanf("%s",newstring);
    send(s,&substring,sizeof(substring),0);

    send(s,&newstring,sizeof(newstring),0);
   
    recv(s,&ack,sizeof(int),0);

    if(ack)
    {
        printf("\nSubstring found & Replaced...\n");
    }
    else
    {
            printf("\nNot found...\n");
    }
    close(s);

}

// testrecord.txt

hi, goodnight...
ok.

Output:

// Terminal 1: (Server)
nn@linuxmint ~ $ gcc sbstrs1.c -o server
nn@linuxmint ~ $ ./server

Substring received: night.
Newstring received: morning.
Substring found.
Replaced.
nn@linuxmint ~ $

// Terminal 2: (Client)
nn@linuxmint ~ $ gcc sbstrc.c -o client
nn@linuxmint ~ $ ./client
Enter the Substring: night

Enter the Newstring: morning

Substring found & Replaced...
nn@linuxmint ~ $


// testrecord.txt
hi, goodmorning...
ok.

String Search and Replacement - Client-Server Program - Network-DBMS Lab - C Program

Program:

// Server : strs.c

#include<stdio.h>
#include<string.h>
#include<sys/stat.h>
#include<sys/types.h>
#include<sys/socket.h>
#include<netinet/in.h>
#include<arpa/inet.h>
#include<stdlib.h>


main ()
{
    struct sockaddr_in client,server;
    int s,sock,found,sz,choice=0,ack=0;
    char buffer[20],string[20],substring[20];
    FILE *fp,*temp;
   
    s=socket(AF_INET,SOCK_STREAM,0);
    server.sin_family=AF_INET;
    server.sin_port=2000;
    server.sin_addr.s_addr=inet_addr("127.0.0.1");
    sz=sizeof(client);
    bind(s,(struct sockaddr *)&server,sizeof(server));
    listen(s,1);
    sock=accept(s,(struct sockaddr *)&client,&sz);
    recv(sock,string,sizeof(string),0);
    printf("String recieved: %s",string);
    found=0;
    if((fp=fopen("testrecord.txt","r"))==NULL)
    {
        printf("! The file is empty...\n");
        send(sock,&found,sizeof(int),0);
    }
    else
    {
        while(!feof(fp)&&found==0)
                {
                    fscanf(fp,"%s",buffer);
                    if(strcmp(buffer,string)==0)
                    {
                        found=1;
                printf("\nThe record found.\n");
            }
        }
        send(sock,&found,sizeof(int),0);
        fclose(fp);
    }
   
   
    recv(sock,&choice,sizeof(int),0);
    if(choice)
    {
       
        recv(sock,substring,sizeof(substring),0);
        printf("\nString Replacement:\nSubstring: %s",substring);
        temp=fopen("temp.txt","w");
        if((fp=fopen("testrecord.txt","r"))==NULL)
        {
            printf("! The file is empty...\n");
            send(sock,&ack,sizeof(int),0);
        }
        else
        {
           
            while(!feof(fp))
                {
                    fscanf(fp,"%s",buffer);
                           if(strcmp(buffer,string)==0)
                           {
                               fprintf(temp,"%s ",substring);
                    ack=1;                                               
                }
                else
                {
                    fprintf(temp,"%s ",buffer);
                }
            }
            send(sock,&ack,sizeof(int),0);
        }
        fclose(fp);
        fclose(temp);
        remove("testrecord.txt");
                rename("temp.txt","testrecord.txt");
                remove("temp.txt");
    }
    else
    {
        printf("\nNo replacement... \n");
            exit(0);
    }   
   
    close(sock);
    close(s);
}

// Client: strc.c

#include<stdio.h>
#include<string.h>
#include<sys/stat.h>
#include<sys/types.h>
#include<sys/socket.h>
#include<netinet/in.h>
#include<arpa/inet.h>
#include<stdlib.h>

main()
{
    struct sockaddr_in client;
    int s,found=0,choice=0,ack=0;;
    char buffer[20],string[20],substring[20];
   
   
    s=socket(AF_INET,SOCK_STREAM,0);
    client.sin_family=AF_INET;
    client.sin_port=2000;
    client.sin_addr.s_addr=inet_addr("127.0.0.1");
    connect(s,(struct sockaddr *)&client,sizeof(client));
   
    printf("Enter a string to search in server:");
    scanf("%s",string);
    send(s,&string,sizeof(string),0);
    recv(s,&found,sizeof(int),0);
    if(found)
    {
        printf("\nThe record found.");
    }
    else
    {
            printf("\nNot found...\n");
            exit(0);
    }
   
    printf("\nDo you want to replace it ?\nEnter 1 -> Yes 2 -> No\n");
    scanf("%d",&choice);
    send(s,&choice,sizeof(int),0);
    if(choice)
    {
        printf("\nSubstring: ");
        scanf("%s",substring);
        send(s,&substring,sizeof(substring),0);
        recv(s,&ack,sizeof(int),0);
        if(ack)
        {
                printf("\nSuccess... \n");
        }
        else
        {
                printf("\nError... \n");
        }
    }
    else
    {
        printf("\nThanks... ");
            exit(0);
    }
    close(s);

}

// testrecord.txt

BAJAJ YAMAHA HONDA HEROHONDA TVS SUZUKI

Output:

Terminal 1: (Server)
nn@linuxmint ~ $ gcc strs.c -o server
nn@linuxmint ~ $ ./server
String recieved: HEROHONDA
The record found.

String Replacement:
Substring: HEROnn@linuxmint ~ $

Terminal 2: (Client)
nn@linuxmint ~ $ gcc strc.c -o client
nn@linuxmint ~ $ ./client
Enter a string to search in server:HEROHONDA

The record found.
Do you want to replace it ?
Enter 1 -> Yes 2 -> No
1

Substring: HERO

Success... nn@linuxmint ~ $

// testrecord.txt

BAJAJ YAMAHA HONDA HERO TVS SUZUKI

Convert Lowercase to Uppercase & Reverse - Lex Progam - Compiler Design

CHANGE CASE - LEX - PROGRAM


Program:

// Lex file: cap.l


lower [a-z]
CAPS  [A-Z]
space    [ \t\n]

%%
{lower}         {printf("%c",yytext[0]- 32);}
{CAPS}        {printf("%c",yytext[0]+ 32);}
{space}        ECHO;
.                    ECHO;
%%

main()
{
    yylex();
   
}

Output:
nn@linuxmint ~ $ lex cap.l
nn@linuxmint ~ $ gcc lex.yy.c -ll
nn@linuxmint ~ $ ./a.out<tst.txt
WWW.2K8618.BLOGSPOT.COM
sanjana    jamsheena chaithanya neethu
GOVINDAPRASAD VIPIN ADARSH SHIVIN
baby brinda kavya helen
SALMAN TINU RICHARD  SIBIN
SHIVIN laji NABEEL
www.2k8cse.cu.cc
nn@linuxmint ~ $

// tst.txt

www.2k8618.blogspot.com
SANJANA    JAMSHEENA CHAITHANYA NEETHU
govindaprasad vipin adarsh shivin
BABY BRINDA KAVYA HELEN
salman tinu richard  sibin
shivin LAJI nabeel
WWW.2K8CSE.CU.CC
Related Posts Plugin for WordPress, Blogger...