Cse Labs
Cse Labs
Objectives:
• To make the student learn a programming language.
• To teach the student to write programs in C solve the problems
• To Introduce the student to simple linear and non linear data structures such as lists, stacks,
queues, trees and graphs.
Recommended Systems/Software Requirements:
• Intel based desktop PC
• ANSI C Compiler with Supporting Editors
Week l.
a) Write a C program to find the sum of individual digits of a positive integer.
b) A Fibonacci Sequence is defined as follows: the first and second terms in the sequence are 0 and 1.
Subsequent terms are found by adding the preceding two terms in the sequence. Write a C program to
generate the first n terms of the sequence.
c) Write a C program to generate all the prime numbers between 1 and n, where n is a value supplied by
the user.
Week 2.
a) Write a C program to calculate the following Sum:
Sum=1-x2/2! +x4/4!-x6/6!+x8/8!-x10/10!
b) Write a C program toe find the roots of a quadratic equation.
Week 3
a) Write C programs that use both recursive and non-recursive functions
i) To find the factorial of a given integer.
ii) To find the GCD (greatest common divisor) of two given integers.
iii) To solve Towers of Hanoi problem.
Week 4
a) The total distance travelled by vehicle in ‘t’ seconds is given by distance = ut+1/2at2 where ‘u’ and ‘a’
are the initial velocity (m/sec.) and acceleration (m/sec2). Write C program to find the distance travelled at
regular intervals of time given the values of ‘u’ and ‘a’. The program should provide the flexibility to the
user to select his own time intervals and repeat the calculations for different values of ‘u’ and ‘a’.
b) Write a C program, which takes two integer operands and one operator form the user, performs the
operation and then prints the result. (Consider the operators +,-,*, /, % and use Switch Statement)
Week 5
a) Write a C program to find both the larges and smallest number in a list of integers.
b) Write a C program that uses functions to perform the following:
i) Addition of Two Matrices
ii) Multiplication of Two Matrices
Week 6
a) Write a C program that uses functions to perform the following operations:
i) To insert a sub-string in to given main string from a given position.
ii) To delete n Characters from a given position in a given string.
b) Write a C program to determine if the given string is a palindrome or not
Week 7
a) Write a C program that displays the position or index in the string S where the string T begins, or – 1 if
S doesn’t contain T.
b) Write a C program to count the lines, words and characters in a given text.
Week 8
a) Write a C program to generate Pascal’s triangle.
b) Write a C program to construct a pyramid of numbers.
2007-2008 Page 19 of 95
Week 9
Write a C program to read in two numbers, x and n, and then compute the sum of this geometric
progression:
1+x+x2+x3+………….+xn
For example: if n is 3 and x is 5, then the program computes 1+5+25+125.
Print x, n, the sum
Perform error checking. For example, the formula does not make sense for negative exponents – if n is
less than 0. Have your program print an error message if n<0, then go back and read in the next pair of
numbers of without computing the sum. Are any values of x also illegal ? If so, test for them too.
Week 10
a) 2’s complement of a number is obtained by scanning it from right to left and complementing all the bits
after the first appearance of a 1. Thus 2’s complement of 11100 is 00100. Write a C program to find the
2’s complement of a binary number.
b) Write a C program to convert a Roman numeral to its decimal equivalent.
Week 11
Write a C program that uses functions to perform the following operations:
i) Reading a complex number
ii) Writing a complex number
iii) Addition of two complex numbers
iv) Multiplication of two complex numbers
(Note: represent complex number using a structure.)
Week 12
a) Write a C program which copies one file to another.
b) Write a C program to reverse the first n characters in a file.
(Note: The file name and n are specified on the command line.)
Week 13
Write a C program that uses functions to perform the following operations on singly linked list.:
i) Creation ii) Insertion iii) Deletion iv) Traversal
Week 14
Write a C program that uses functions to perform the following operations on doubly linked list.:
i) Creation ii) Insertion iii) Deletion iv) Traversal in both ways
Week 15
Write C programs that implement stack (its operations) using
i) Arrays ii) Pointers
Week 16
Write C programs that implement Queue (its operations) using
i) Arrays ii) Pointers
Week 17
Write a C program that uses Stack operations to perform the following:
i) Converting infix expression into postfix expression
ii) Evaluating the postfix expression
Week 18
Write a C program that uses functions to perform the following:
i) Creating a Binary Tree of integers
ii) Traversing the above binary tree in preorder, inorder and postorder.
Week 19
Write C programs that use both recursive and non recursive functions to perform the following searching
operations for a Key value in a given list of integers :
i) Linear search ii) Binary search
Week 20
Write C programs that implement the following sorting methods to sort a given list of integers in ascending
order:
i) Bubble sort ii) Quick sort
2007-2008 Page 20 of 95
Week 21
Write C programs that implement the following sorting methods to sort a given list of integers in ascending
order:
i) Insertion sort ii) Merge sort
Week 22
Write C programs to implement the Lagrange interpolation and Newton- Gregory forward interpolation.
Week 23
Write C programs to implement the linear regression and polynomial regression algorithms.
Week 24
Write C programs to implement Trapezoidal and Simpson methods.
Text Books
1. C programming and Data Structures, P. Padmanabham, Third Edition, BS Publications
2. Data Structures: A pseudo code approach with C, second edition R.F. Gilberg and B.A. Forouzan
3. Programming in C, P.Dey & M. Ghosh, Oxford Univ.Press.
4. C and Data Structures, E Balaguruswamy, TMH publications.
UNIX AND SHELL PROGRAMMING LAB
Objectives:
• To teach students various unix utilities and shell scripting
Recommended Systems/Software Requirements:
• Intel based desktop PC with minimum of 166 MHZ or faster processor with atleast 64 MB RAM
and 100 MB free disk space LAN Connected
• Any flavour of Unix / Linux
Week1
Session-1
a)Log into the system
b)Use vi editor to create a file called myfile.txt which contains some
text.
c)correct typing errors during creation.
d)Save the file
e)logout of the system
Session-2
a)Log into the system
b)open the file created in session 1
c)Add some text
d)Change some text
e)Delete some text
f)Save the Changes
g)Logout of the system
Week2
a)Log into the system
b)Use the cat command to create a file containing the following data. Call it mytable use tabs to separate
the fields.
1425 Ravi 15.65
4320 Ramu 26.27
6830 Sita 36.15
1450 Raju 21.86
c)Use the cat command to display the file, mytable.
d)Use the vi command to correct any errors in the file, mytable.
e)Use the sort command to sort the file mytable according to the first field. Call the sorted file my table
(same name)
f)Print the file mytable
g)Use the cut and paste commands to swap fields 2 and 3 of mytable. Call it my table (same name)
h)Print the new file, mytable
i)Logout of the system.
Week3
1) a)Login to the system
b)Use the appropriate command to determine your login shell
c)Use the /etc/passwd file to verify the result of step b.
d)Use the who command and redirect the result to a file called myfile1. Use the more command
to see the contents of myfile1.
e)Use the date and who commands in sequence (in one line) such that the output of date will
display on the screen and the output of who will be redirected to a file called myfile2. Use the
more command to check the contents of myfile2.
2) a)Write a sed command that deletes the first character in each line in a
file.
b)Write a sed command that deletes the character before the last character in each line in a file.
c)Write a sed command that swaps the first and second words in each line in a file.
Week4
2007-2008 Page 38 of 95
a)Pipe your /etc/passwd file to awk, and print out the home directory of each user.
b)Develop an interactive grep script that asks for a word and a file name and then tells how many lines
contain that word.
c)Repeat
d)Part using awk
Week5
a)Write a shell script that takes a command –line argument and reports on whether it is directory, a file, or
something else.
b)Write a shell script that accepts one or more file name as arguments and converts all of them to
uppercase, provided they exist in the current directory.
c)Write a shell script that determines the period for which a specified user is working on the system.
Week6
a)Write a shell script that accepts a file name starting and ending line numbers as arguments and displays
all the lines between the given line numbers.
b)Write a shell script that deletes all lines containing a specified word in one or more files supplied as
arguments to it.
Week7
a)Write a shell script that computes the gross salary of a employee according to the following rules:
i)If basic salary is < 1500 then HRA =10% of the basic and DA =90% of the basic.
ii)If basic salary is >=1500 then HRA =Rs500 and DA=98% of the basic
The basic salary is entered interactively through the key board.
b)Write a shell script that accepts two integers as its arguments and computers the value of first number
raised to the power of the second number.
Week8
a)Write an interactive file-handling shell program. Let it offer the user the choice of copying, removing,
renaming, or linking files. Once the user has made a choice, have the program ask the user for the
necessary information, such as the file name, new name and so on.
b)Write shell script that takes a login name as command – line argument and reports when that person
logs in
c)Write a shell script which receives two file names as arguments. It should check whether the two file
contents are same or not. If they are same then second file should be deleted.
Week9
a)Write a shell script that displays a list of all the files in the current directory to which the user has read,
write and execute permissions.
b)Develop an interactive script that ask for a word and a file name and then tells how many times that
word occurred in the file.
c)Write a shell script to perform the following string operations:
i)To extract a sub-string from a given string.
ii)To find the length of a given string.
Week10
Write a C program that takes one or more file or directory names as command line input and reports the
following information on the file:
i)File type
ii)Number of links
iii)Read, write and execute permissions
iv)Time of last access
(Note : Use stat/fstat system calls)
Week11
Write C programs that simulate the following unix commands:
a)mv
b)cp
(Use system calls)
Week12
Write a C program that simulates ls Command
(Use system calls / directory API)
TEXT BOOKS
2007-2008 Page 39 of 95
1)Introduction to UNIX & SHELL programming, M.G. Venkatesh Murthy, Pearson Education.
2)Unix concepts and applications, Fourth Edition, Sumitabha Das, TMH.
3)Unix for programmers and users, 3rd edition, Gaham Glass & K. Ables, pearson education.
4)Unix and shell Programming –A text book, B.A. Forouzan & R.F. Giberg, Thomson.
5)Beginning shell scripting, E. Foster – Johnson & other, Wile Y- India.
2007-2008 Page 36 of 95
2.Data Structures using C++, D.S. Malik, Thomson
2007-2008 Page 49 of 95
b) Write a Java program that correctly implements producer consumer problem using the concept of inter
thread communication.
Week 10 :
Write a program that creates a user interface to perform integer divisions. The user enters two numbers in
the textfields, Num1 and Num2. The division of Num1 and Num2 is displayed in the Result field when the
Divide button is clicked. If Num1 or Num2 were not an integer, the program would throw a
NumberFormatException. If Num2 were Zero, the program would throw an ArithmeticException Display
the exception in a message dialog box.
Week 11 :
Write a Java program that implements a simple client/server application. The client sends data to a server.
The server receives the data, uses it to produce a result, and then sends the result back to the client. The
client displays the result on the console. For ex: The data sent from the client is the radius of a circle, and
the result produced by the server is the area of the circle. (Use java.net)
Week 12 :
a) Write a java program that simulates a traffic light. The program lets the user select one of three lights:
red, yellow, or green. When a radio button is selected, the light is turned on, and only one light can be on
at a time No light is on when the program starts.
b) Write a Java program that allows the user to draw lines, rectangles and ovals.
Week 13 :
a) Write a java program to create an abstract class named Shape that contains an empty method named
numberOfSides ( ).Provide three classes named Trapezoid, Triangle and Hexagon such that each one of
the classes extends the class Shape. Each one of the classes contains only the method numberOfSides
( ) that shows the number of sides in the given geometrical figures.
b) Suppose that a table named Table.txt is stored in a text file. The first line in the file is the header, and
the remaining lines correspond to rows in the table. The elements are 49eparated by commas. Write a
java program to display the table using Jtable component.
TEXT BOOKS :
1. Java How to Program, Sixth Edition, H.M.Dietel and P.J.Dietel, Pearson
Education/PHI
2. Introduction to Java programming, Sixth edition, Y.Daniel Liang, Pearson Education
2007-2008 Page 50 of 95
JAWAHARLAL NEHRU TECHNOLOGICAL UNIVERSITY
KAKINADA
II Year B.Tech. CSE -II Sem T P C
0 3 2
DATA BASE MANAGEMENT SYSTEMS LAB
Objectives: To teach the student database design and query and PL/SQL.
Recommended Systems/Software Requirements:
• Intel based desktop PC
• Mysql /Oracle latest version Recommended
1) Creation, altering and droping of tables and inserting rows into a table (use constraints while
creating tables) examples using SELECT command.
2) Queries (along with sub Queries) using ANY, ALL, IN, EXISTS, NOTEXISTS, UNION,
INTERSET, Constraints.
Example:- Select the roll number and name of the student who secured fourth rank in the class.
3) Queries using Aggregate functions (COUNT, SUM, AVG, MAX and MIN), GROUP BY, HAVING
and Creation and dropping of Views.
4) Queries using Conversion functions (to_char, to_number and to_date), string functions
(Concatenation, lpad, rpad, ltrim, rtrim, lower, upper, initcap, length, substr and instr), date
functions (Sysdate, next_day, add_months, last_day, months_between, least, greatest, trunc,
round, to_char, to_date)
5) i)Creation of simple PL/SQL program which includes declaration section, executable section and
exception –Handling section (Ex. Student marks can be selected from the table and printed for
those who secured first class and an exception can be raised if no records were found)
ii)Insert data into student table and use COMMIT, ROLLBACK and SAVEPOINT in PL/SQL
block.
6) Develop a program that includes the features NESTED IF, CASE and CASE expression. The
program can be extended using the NULLIF and COALESCE functions.
7) Program development using WHILE LOOPS, numeric FOR LOOPS, nested loops using ERROR
Handling, BUILT –IN Exceptions, USE defined Exceptions, RAISE- APPLICATION ERROR.
8) Programs development using creation of procedures, passing parameters IN and OUT of
PROCEDURES.
9) Program development using creation of stored functions, invoke functions in SQL Statements
and write complex functions.
10) Program development using creation of package specification, package bodies, private objects,
package variables and cursors and calling stored packages.
11) Develop programs using features parameters in a CURSOR, FOR UPDATE CURSOR, WHERE
CURRENT of clause and CURSOR variables.
12) Develop Programs using BEFORE and AFTER Triggers, Row and Statement Triggers and
INSTEAD OF Triggers
TEXT BOOKS :
1)ORACLE PL/SQL by example. Benjamin Rosenzweig, Elena Silvestrova, Pearson
Education 3rd Edition
2)ORACLE DATA BASE LOG PL/SQL Programming SCOTT URMAN, Tata Mc-
Graw Hill.
3)SQL & PL/SQL for Oracle 10g, Black Book, Dr.P.S. Deshpande.
COMPUTER NETRWORKS AND CASE TOOLS LAB
Objective:
2007-2008 Page 69 of 95
worry about the scoping of names.
A simple program written in this language is:
{ int a[3],t1,t2;
t1=2;
a[0]=1; a[1]=2; a[t1]=3;
t2=-(a[2]+t1*6)/(a[2]-t1);
if t2>5 then
print(t2);
else {
int t3;
t3=99;
t2=-25;
print(-t1+t2*t3); /* this is a comment
on 2 lines */
} endif }
1. Design a Lexical analyzer for the above language. The lexical analyzer should ignore redundant
spaces, tabs and newlines. It should also ignore comments. Although the syntax specification
states that identifiers can be arbitrarily long, you may restrict the length to some reasonable value.
2. Implement the lexical analyzer using JLex, flex or lex or other lexical analyzer generating tools.
3. Design Predictive parser for the given language
4. Design LALR bottom up parser for the above language.
5. Convert the BNF rules into Yacc form and write code to generate abstract syntax tree.
6. Write program to generate machine code from the abstract syntax tree generated by the parser. The
following instruction set may be considered as target code.
The following is a simple register-based machine, supporting a total of 17 instructions. It has three distinct
internal storage areas. The first is the set of 8 registers, used by the individual instructions as detailed
below, the second is an area used for the storage of variables and the third is an area used
for the storage of program. The instructions can be preceded by a label. This consists of an integer in the
range 1 to 9999 and the label is followed by a colon to separate it from the rest of the instruction. The
numerical label can be used as the argument to a jump instruction, as detailed below.
In the description of the individual instructions below, instruction argument types are specified as follows :
R
specifies a register in the form R0, R1, R2, R3, R4, R5, R6 or R7 (or r0, r1, etc.).
L
specifies a numerical label (in the range 1 to 9999).
V
specifies a “variable location” (a variable number, or a variable location pointed to by a register - see
below).
A
specifies a constant value, a variable location, a register or a variable location pointed to by a register (an
indirect address). Constant values are specified as an integer value, optionally preceded by a minus sign,
preceded by a # symbol. An indirect address is specified by an @ followed by a register.
So, for example, an A-type argument could have the form 4 (variable number 4), #4 (the constant value 4),
r4 (register 4) or @r4 (the contents of register 4 identifies the variable location to be accessed).
The instruction set is defined as follows:
LOAD A,R
loads the integer value specified by A into register R.
STORE R,V
stores the value in register R to variable V.
OUT R
outputs the value in register R.
NEG R
negates the value in register R.
ADD A,R
adds the value specified by A to register R, leaving the result in register R.
SUB A,R
subtracts the value specified by A from register R, leaving the result in register R.
MUL A,R
multiplies the value specified by A by register R, leaving the result in register R.
DIV A,R
divides register R by the value specified by A, leaving the result in register R.
JMP L
causes an unconditional jump to the instruction with the label L.
JEQ R,L
jumps to the instruction with the label L if the value in register R is zero.
JNE R,L
jumps to the instruction with the label L if the value in register R is not zero.
JGE R,L
jumps to the instruction with the label L if the value in register R is greater than or equal to zero.
JGT R,L
jumps to the instruction with the label L if the value in register R is greater than zero.
JLE R,L
jumps to the instruction with the label L if the value in register R is less than or equal to zero.
JLT R,L
jumps to the instruction with the label L if the value in register R is less than zero.
NOP
is an instruction with no effect. It can be tagged by a label.
STOP
stops execution of the machine. All programs should terminate by executing a STOP instruction.
NETWORK PROGRAMMING LAB
Objectives:
• To teach students various forms of IPC through Unix and socket Programming
Recommended Systems/Software Requirements:
• Intel based desktop PC with minimum of 166 MHZ or faster processor with atleast 64 MB RAM
and 100 MB free disk space LAN Connected
• Any flavour of Unix / Linux
Week1.
Implement the following forms of IPC.
a)Pipes
b)FIFO
Week2.
Implement file transfer using Message Queue form of IPC
Week3.
Write a programme to create an integer variable using shared memory concept and increment the variable
simultaneously by two processes. Use senphores to avoid race conditions
Week4.
Design TCP iterative Client and server application to reverse the given input sentence
Week5.
Design TCP iterative Client and server application to reverse the given input sentence
Week6.
Design TCP client and server application to transfer file
Week7.
Design a TCP concurrent server to convert a given text into upper case using multiplexing system call
“select”
Week8.
Design a TCP concurrent server to echo given set of sentences using poll functions
Week9.
Design UDP Client and server application to reverse the given input sentence
Week10
Design UDP Client server to transfer a file
Week11
Design using poll client server application to multiplex TCP and UDP requests for converting a given text
into upper case.
Week12
Design a RPC application to add and subtract a given pair of integers
Reference Book:
1.Advance Unix Programming Richard Stevens, Second Edition Pearson Education
2. Advance Unix Programming, N.B. Venkateswarlu, BS Publication.
WEB TECHNOLOGIES LAB
Objective :
To create a fully functional website with mvc architecture. To Develop an online Book store
using we can sell books (Ex amazon .com).
Hardware and Software required :
1. A working computer system with either Windows or Linux
2. A web browser either IE or firefox
3. Tomcat web server and Apache web server