0% found this document useful (0 votes)
45 views

Cse Labs

The document outlines a 24-week computer programming lab course covering programming in C and data structures. Over the course of the labs, students will: - Learn the C programming language and write programs to solve problems involving algorithms like prime number generation, Fibonacci sequences, and quadratic equations. - Be introduced to linear and non-linear data structures like lists, stacks, queues, trees and graphs. - Implement data structures and algorithms using arrays and pointers including stacks, queues, linked lists, binary trees, sorting, and searching. - Write programs involving file handling, string manipulation, recursion, and dynamic memory allocation. - Implement numerical methods like numerical integration, interpolation, regression and solutions to differential

Uploaded by

kakhani
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
45 views

Cse Labs

The document outlines a 24-week computer programming lab course covering programming in C and data structures. Over the course of the labs, students will: - Learn the C programming language and write programs to solve problems involving algorithms like prime number generation, Fibonacci sequences, and quadratic equations. - Be introduced to linear and non-linear data structures like lists, stacks, queues, trees and graphs. - Implement data structures and algorithms using arrays and pointers including stacks, queues, linked lists, binary trees, sorting, and searching. - Write programs involving file handling, string manipulation, recursion, and dynamic memory allocation. - Implement numerical methods like numerical integration, interpolation, regression and solutions to differential

Uploaded by

kakhani
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 19

COMPUTER PROGRAMMING LAB

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.

ADVANCED DATA STRUCTURES LAB


Objectives:
• To make the student learn a object oriented way of solving problems.
• To make the student write ADTS for all data structures.
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

• C++ compiler and STL Recommended


Week1 :
C++ programs to implement the following using an array.
a) Stack ADT b) Queue ADT
Week2 :
Write C++ programs to implement the following using a singly linked list.
a) Stack ADT b) Queue ADT
Week3 :
Write C++ programs to implement the deque (double ended queue) ADT using a doubly linked list and an
array.
Week 4 :
Write a C++ program to perform the following operations:
a) Insert an element into a binary search tree.
b) Delete an element from a binary search tree.
c) Search for a key element in a binary search tree.
Week5 :
.Write C++ programs that use non-recursive functions to traverse the given
binary tree in
a) Preorder b) inorder and c) postorder.
Week6 :
Write C++ programs for the implementation of bfs and dfs for a given graph.
Week7 :
Write C++ programs for implementing the following sorting methods:
a) Merge sort b) Heap sort
Week8 :
Write a C++ program to perform the following operations
a) Insertion into a B-tree b) Deletion from a B-tree
Week9 :
.Write a C++ program to perform the following operations
a) Insertion into an AVL-tree b) Deletion from an AVL-tree
Week10 :
Write a C++ program to implement all the functions of a dictionary (ADT)
using hashing.
Week11 :
Write a C++ program for implementing Knuth-Morris- Pratt pattern matching
algorithm.
Week12 :
Write a C++ program for implementing Boyer – Moore Patten matching
algorithm
(Note: Use Class Templates in the above Programs)
TEXT BOOKS :
1. Data Structures and Algorithms in C++, Third Edition, Adam Drozdek, Thomson.

2007-2008 Page 36 of 95
2.Data Structures using C++, D.S. Malik, Thomson

OBJECT ORIENTED PROGRAMMING LAB


Objectives:
• To make the student learn a object oriented way of solving problems.
• To teach the student to write programs in Java to solve the problems
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
• JDK Kit. Recommended
Week1 :
a) Write a Java program that prints all real solutions to the quadratic equation ax2 + bx + c = 0. Read in a,
b, c and use the quadratic formula. If the discriminant b2 -4ac is negative, display a message stating that
there are no real solutions.
b) The Fibonacci sequence is defined by the following rule:
The fist two values in the sequence are 1 and 1. Every subsequent value is the sum of the two values
preceding it. Write a Java program that uses both recursive and non recursive functions to print the nth
value in the Fibonacci sequence.
Week 2 :
a) Write a Java program that prompts the user for an integer and then prints out all prime numbers up to
that integer.
b) Write a Java program to multiply two given matrices.
c) Write a Java Program that reads a line of integers, and then displays each integer, and the sum of all
the integers (Use StringTokenizer class of java.util)
Week 3 :
a) Write a Java program that checks whether a given string is a palindrome or not. Ex: MADAM is a
palindrome.
b) Write a Java program for sorting a given list of names in ascending order.
c) Write a Java program to make frequency count of words in a given text.
Week 4 :
a) Write a Java program that reads a file name from the user, then displays information about whether the
file exists, whether the file is readable, whether the file is writable, the type of file and the length of the file
in bytes.
b) Write a Java program that reads a file and displays the file on the screen, with a line number before
each line.
c) Write a Java program that displays the number of characters, lines and words in a text file.
Week 5 :
a) Write a Java program that:
i) Implements stack ADT.
ii) Converts infix expression into Postfix form
iii) Evaluates the postfix expression
Week 6 :
a) Develop an applet that displays a simple message.
b) Develop an applet that receives an integer in one text field, and computes its factorial Value and
returns it in another text field, when the button named “Compute” is clicked.
Week 7 :
Write a Java program that works as a simple calculator. Use a grid layout to arrange buttons for the digits
and for the +, -,*, % operations. Add a text field to display the result.
Week 8 :
a) Write a Java program for handling mouse events.
Week 9 :
a) Write a Java program that creates three threads. First thread displays “Good Morning” every one
second, the second thread displays “Hello” every two seconds and the third thread displays “Welcome”
every three seconds.

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

3. Big Java, 2nd


edition, Cay Horstmann, Wiley Student Edition, Wiley India Private Limited.

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:

• To Understand the functionalities of various layers of OSI model


• To inculcate object oriented software design
System/ Software Requirement
• Intel based desktop PCs LAN CONNECTED with minimum of 166 MHZ or faster processor with
atleast 64 MB RAM and 100 MB free disk space
• Tools Such as Rational Rose
Part - A
1. Implement the data link layer framing methods such as character, character stuffing and bit stuffing.
2. Implement on a data set of characters the three CRC polynomials – CRC 12, CRC 16 and CRC CCIP .
3. Implement Dijkstra ‘s algorithm to compute the Shortest path thru a graph.
4. Take an example subnet graph with weights indicating delay between nodes. Now obtain Routing table
art each node using distance vector routing algorithm
5. Take an example subnet of hosts . Obtain broadcast tree for it.
6. Take a 64 bit playing text and encrypt the same using DES algorithm .
7. Write a program to break the above DES coding
8. Using RSA algorithm Encrypt a text data and Decrypt the same .
Part - B
1. The student should take up the case study of Unified Library application which is mentioned in the
theory, and Model it in different views i.e Use case view, logical view, component view, Deployment view,
Database design, forward and Reverse Engineering, and Generation of documentation of
the project.
2. Student has to take up another case study of his/her own interest and do the same what ever
mentioned in first problem. Some of the ideas regarding case studies are given in reference books which
were mentioned in theory syllabus can be referred for some idea.
Note : The analysis, design, coding, documentation, database design of mini project which will be carried
out in 4th year should be done in object-oriented approach using UML and by using appropriate software
which supports UML, otherwise the mini project will not be evaluated.
OPERATING SYSTEMS AND COMPILER DESIGN LAB
Objective :
• To provide an understanding of the language translation peculiarities by designing a complete
translator for a mini language.
• To provide an understanding of the design aspects of operating system
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
• C++ complier and JDK kit
Part - A
1. Simulate the following CPU scheduling algorithms
a) Round Robin b) SJF c) FCFS d) Priority
2. Simulate all file allocation strategies
a) Sequentialb) Indexed c) Linked
3. Simulate MVT and MFT
4. Simulate all File Organization Techniques
a) Single level directory b) Two level c) Hierarchical d) DAG
5. Simulate Bankers Algorithm for Dead Lock Avoidance
6. Simulate Bankers Algorithm for Dead Lock Prevention
7. Simulate all page replacement algorithms
a) FIFO b) LRU c) LFU Etc. …
8. Simulate Paging Technique of memory management.
PART - B
Consider the following mini Language, a simple procedural high-level language, only operating on integer
data, with a syntax looking vaguely like a simple C crossed with Pascal. The syntax of the language is
defined by the following BNF grammar:
<program> ::= <block>
<block> ::= { <variabledefinition> <slist> }
| { <slist> }
<variabledefinition> ::= int <vardeflist> ;
<vardeflist> ::= <vardec> | <vardec> , <vardeflist>
<vardec> ::= <identifier> | <identifier> [ <constant> ]
<slist> ::= <statement> | <statement> ; <slist>
<statement> ::= <assignment> | <ifstatement> | <whilestatement>
| <block> | <printstatement> | <empty>
<assignment> ::= <identifier> = <expression>
| <identifier> [ <expression> ] = <expression>
<ifstatement> ::= if <bexpression> then <slist> else <slist> endif
| if <bexpression> then <slist> endif
<whilestatement> ::= while <bexpression> do <slist> enddo
<printstatement> ::= print ( <expression> )
<expression> ::= <expression> <addingop> <term> | <term> | <addingop> <term>
<bexpression> ::= <expression> <relop> <expression>
<relop> ::= < | <= | == | >= | > | !=
<addingop> ::= + | -
<term> ::= <term> <multop> <factor> | <factor>
<multop> ::= * | /
<factor> ::= <constant> | <identifier> | <identifier> [ <expression>]
| ( <expression> )
<constant> ::= <digit> | <digit> <constant>
<identifier> ::= <identifier> <letterordigit> | <letter>
<letterordigit> ::= <letter> | <digit>
<letter> ::= a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z
<digit> ::= 0|1|2|3|4|5|6|7|8|9
<empty> has the obvious meaning
Comments (zero or more characters enclosed between the standard C/Java-style comment brackets /
*...*/) can be inserted. The language has rudimentary support for 1-dimensional arrays. The declaration
int a[3] declares an array of three elements, referenced as a[0], a[1] and a[2]. Note also that you should

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

4. XML editor like Altova Xml-spy [www.Altova.com/XMLSpy – free ] , Stylusstudio , etc.,


5. A database either Mysql or Oracle
6. JVM(Java virtual machine) must be installed on your system
7. BDK(Bean development kit) must be also be installed
Week-1:
Design the following static web pages required for an online book store web site.
1) HOME PAGE:
The static home page must contain three frames.
Top frame : Logo and the college name and links to Home page, Login page, Registration page,
Catalogue page and Cart page (the description of these pages will be given below).
Left frame : At least four links for navigation, which will display the catalogue of respective links.
For e.g.: When you click the link “CSE” the catalogue for CSE Books should be

You might also like