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

FYBSc - C and DB - Labbook

Uploaded by

shraddh.murade
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views

FYBSc - C and DB - Labbook

Uploaded by

shraddh.murade
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 83

F. Y. B.Sc.

(Computer

Science)

Semester-I

Lab Course – I &

II Work Book

Name:

College Name: _

Roll No.: _ Division:

Academic Year:
1
Savitribai Phule Pune
University

Section
-I

F. Y. B.Sc. (Computer Science)


SEMESTER I

Lab Course –

IC

Programming
2
Introduction

1. About the work book:


This workbook is intended to be used by F.Y BCA students for the C and
RDBMS Assignments in Semester–I. This workbook is designed by
considering all the practical concepts / topics mentioned in syllabus.

2. The objectives of this workbook are:


1) Defining the scope of the course.
2) To bring the uniformity in the practical conduction
and implementation in all colleges affiliated to SPPU.
3) To have continuous assessment of the course and students.
4) Providing ready reference for the students during
practical implementation.
5) Provide more options to students so that they can have good
practice before facing the examination.
6) Catering to the demand of slow and fast learners and accordingly
providing the practice assignments to them.

3. How to use this work book:


C programming is divided into Eleven assignments. Each C
assignment has three SETs. It is mandatory for students to complete
the SET A and SET B in given slot.

Instructions to the students

Please read the following instructions carefully and follow them.

1) Students are expected to carry this book every time they come to
the lab for computer science practical.
2) Students should prepare oneself beforehand for the
Assignment by reading the relevant material.
3) Instructor will specify which problems to solve in the lab during
the allotted slot and student should complete them and get
verified by the instructor. However student should spend
additional hours in Lab and at home to cover as many problems
as possible given in this work book.

3
4) Students will be assessed for each exercise on a scale from 0to5.

Not done 0
Incomplete 1
Late Complete 2
Needs improvement 3
Complete 4
Well Done 5

Instruction to the Instructors

1) Explain the assignment and related concepts in around ten


minutes using whiteboard if required or by
demonstrating the software.
2) You should evaluate each assignment carried out by a
student on a scale of 5 as specified above by ticking
appropriate box.
3) The value should also be entered on assignment
completion page of the respective Lab course.

Instructions to the Lab Administrator

You have to ensure appropriate hardware and software


is made available to each student.

The operating system and software requirements on server


side and also client side areas given below:
1) Server and Client Side - ( Operating System ) Linux/Windows
2) Database server – PostgreSQL
3) Turbo C.
Assignment Completion Sheet

Lab Course I
C Programming
Sr. Assignment Name Marks Teachers
No. (out of 5) Sign
1 Testing the Errors

2 Use of data types, simple operators


(expressions)
3 Use of decision making statements (if and
if-else, nested structures)
4 Use of decision making statements (switch
case)
5 Use of simple loops
6 Use of nested loops
7 Use of standard library functions and
menu driven programs
8 Use of user defined functions)
9 Use of recursive functions.
10 Use of arrays (1-d arrays ) and functions
11 Use of multidimensional array(2-d arrays )
and functions
Total ( Out of 50 )
Total (Out of 08)

This is to certify that Mr./Ms._____________ _______________ ___


Has successfully completed the C programming course work Lab
Course-I and has scored___ Marks out of 08.

Instructor H.O.D. /
Coordinator

Internal Examiner External Examiner


Exercise 1 Start Date / /

Testing the errors

Testing is a process of finding bugs or error in a c program.

Find errors if any in the following program. Justify your answer


1. #include<stdio.h>
void main()
{
int x;
printf(“Enter the value of x”);
scanf(“%d”,x);

2. #include<stdio.h>
void main()
{
printf("hello")
}

3. #include<stdio.h>
void Main()
{
int a = 10;
printf("%d", a);
}

4. void main()
{
int a, b, c;
a + b = c;
}
5. #include<stdio.h>
void main()
{

while(.)
{
printf("hello");
}

Assignment Evaluation Signature


0: Not done 2: Late Complete 4: Complete

1: Incomplete 3: Needs 5: Well Done


improvement
Exercise 2 Start Date
/ /

To demonstrate the use of data types, simple operators and expressions

You should read following topics before starting this exercise


1. Different basic data types in C and rules of declaring variables in C
2. Different operators and operator symbols in C
3. How to construct expressions in C, operator precedence
4. Problem solving steps- writing algorithms and flowcharts

1. Data type Table

Data Data C Data C Variable Input Statement Output


Format Type declaration statement
quanti Numeric int int scanf(“%d”,&quantity); printf(“The
ty Shor quantity; scanf(“%d”,&month) quantity is
month t int short ; %d”,
credit- long int month; scanf(“%ld”, &ccno); quantity);
card long ccno; printf(“The
numbe credit card
r number is
%ld, ccno);
price real float float price; scanf(“%f”,&price); printf(“The price
 double const is
double %5.2f”, price);
pi=3.14159
3;
grade characte char grade; scanf(“%c”,&grade) printf(“The grade
r is %c”,grade);

2. Expression Examples

Expression C expression
Increment by a 3 a=a+3
Decrement b by 1 b = b-1 or b--
2 a2 + 5 b/2 2*a*a + 5*b/2
7/13(x-5) (float)7/13*(x-5)
5% of 56 (float)5/100*56
n is between 12 to 70 n>=12 && n<=70
r2h Pi*r*r*h
n is not divisible by 7 n % 7 != 0
n is even n%2== 0
ch is an alphabet ch>=’A’ && ch<=’Z’ || ch>=’a’ && ch<=’z’
Note: The operators in the above expressions will be executed according to
precedence and associativity rules of operators.

3. Sample program- to calculate and print simple interest after accepting principal
sum, number of years and rate of interest.
Program development steps

Step 1 : Step 2 : Draw the Step 3 : Writing Program


Writing the flowchart
Algorithm
1. Start /* Program to calculate simple
2. Accept star interest */ #include <stdio.h>
principal t main( )
sum, rate { /* variable declarations */
of interest float amount, rateOfInterest,
and Read ,princip simpleInterest; int noOfYears;
number al sum, rate /* prompting and accepting
of years and no of input */ printf(“Give the
3. Comput years Principal Sum”);
e scanf(“%f”,&amount);
Simple printf(“Give the Rate of
interest Interest”);
Compute
4. Outpu scanf(“%f”,&rateOfInterest);
Simple
t interest printf(“Give the Number of
Simpl years”);
e scanf(“%d”,&noOfYears);
Intere
st Print /* Compute the simple Interest*/
5. Stop Simple simpleInterest=amount*noOfYears*rateOfIn
Interest terest / 100;

/* Print the result*/


printf(“The simple Interest on amount %7.2f
stop for %d years at the rate %4.2f is %6.2f”,
amount, noOfYears, rateOfInterest,
simpleInterest);
}

1. Type the sample program given above. Execute it for the different values as
given below and fill the last column from the output given by the program.
Follow the following guidelines
a. At $ prompt type vi followed by filename. The filename should have .c as
extension for example
$vi pnr.c
b. Type the sample program given above using vi commands
and save it Compile the program using cc compiler available in
Linux
$cc pnr.c
It will give errors if any or it will give back the $ prompt if there are no errors
A executable file a.out is created by the compiler in current directory. The program
can be executed by typing name of the file as follows giving the path.
$ ./a.out
Alternatively the executable file can be given name by using –o option while
compiling as follows
$cc pnr.c –o pnrexec
$./pnrexec
The executable file by specified name will be created. Note that you have to
specify the path of pnrexec as ./pnrexec , i. e., pnrexec in current (. Stands for
current directory) directory otherwise it looks for program by that name in the
path specified for executable programs

Sr. No Principal sum No of years Rate of interest Simple Interest


1 2000 3
2 4500 4.5
3 _ 6 8.3
2. If you have not typed the program correctly,i.e., if there are syntactical errors in
the program, compiler will pinpoint the errors committed and are called compile-
time errors. C compiler gives line no along with error messages when it detects
grammatical or syntactical errors in the program. These messages are not so
straightforward and you may find it difficult to identify the error. You may miss a
semicolon at the end of a statement and the compiler points out error in the next
statement. You may miss just a closing ‘*/’ of a comment and it will show errors in
several statements following it.
Another type of error which is quite common is the run-time or execution error.
You are able to compile the program successfully but you get run-time messages
or garbage output when you execute the program.
Modify the above program to introduce the following changes, compile, write the
error messages along with line numbers ,remove the error execute and indicate
the type of error whether it was compile-time or execution time error.

Modified line Error messages and line Type of error


numbers
/* Program to calculate
simple interest

int noofYears;

scanf(“%f”,&amount)

scanf(“%f”, amount);

scanf(“%d”, noOfYears);

Signature of the instructor Date / /

Set A . Apply all the three program development steps for the following examples.
1. Accept dimensions of a cylinder and print the surface area and volume
(Hint: surface area = 2r2 + 2rh, volume = r2h)
2. Accept temperatures in Fahrenheit (F) and print it in Celsius(C) and Kelvin
(K) (Hint: C=5/9(F- 32), K = C + 273.15)
3. Accept initial velocity (u), acceleration (a) and time (t). Print the final
velocity (v) and the distance (s) travelled. (Hint: v = u + at, s = u + at2)
4. Accept inner and outer radius of a ring and print the perimeter and area
of the ring (Hint: perimeter = 2  (a+b) , area =  (a2-b2) )
5. Accept two numbers and print arithmetic and harmonic mean of the two
numbers (Hint: AM= (a+b)/2 , HM = ab/(a+b) )
6. Accept three dimensions length (l), breadth(b) and height(h) of a
cuboid and print surface area and volume (Hint : surface
area=2(lb+lh+bh ), volume = lbh )
7. Accept a character from the keyboard and display its previous and next
character in order. Ex. If the character entered is ‘d’, display “The previous
character is c”, “The next character is e”.
8. Accept a character from the user and display its ASCII value.

Signature of the instructor Date / /


Set B . Apply all the three program development steps for the following examples.
1. Accept the x and y coordinates of two points and compute the distance between the two
points.
2. Accept two integers from the user and interchange them. Display the interchanged
numbers.
3. A cashier has currency notes of denomination 1, 5 and 10. Accept the amount
to be withdrawn from the user and print the total number of currency notes of
each denomination the cashier will have to give.

Signature of the instructor Date / /

Set C. Write a program to solve the following problems


1. Consider a room having one door and two windows both of the same size.
Accept dimensions of the room, door and window. Print the area to be
painted (interior walls) and area to be whitewashed (roof).
2. The basic salary of an employee is decided at the time of employment, which
may be different for different employees. Apart from basic, employee gets
10% of basic as house rent, 30% of basic as dearness allowance. A
professional tax of 5% of basic is deducted from salary. Accept the employee
id and basic salary for an employee and output the take home salary of the
employee.
.
Signature of the instructor Date / /

Assignment Evaluation Signature


0: Not done 2: Late Complete 4: Complete

1: Incomplete 3: Needs 5: Well Done


improvement
Exercise 3 Start Date / /

To demonstrate use of decision making statements such as if and if-else.

You should read following topics before starting this exercise


1. Different types of decision-making statements available in C.
2. Syntax for these statements.

During problem solving, we come across situations when we have to choose one of
the alternative paths depending upon the result of some condition. Condition is an
expression evaluating to true or false. This is known as the Branching or decision-
making statement. Several forms of If and else constructs are used in C to support
decision-making.
1) if statements
2) if – else
3) Nested if

Note: If there are more than one statement in the if or else part, they have to be
enclosed in { } braces

Sr. Statement Flowchart Example


No Syntax
1. if statement
if( n > 0)
if (condition) If False printf(“Num
{ condition ? ber is
statement; positive”);
}
True
statement

New statement
2. if - else
statement if( n % 2 == 0)
printf(“Even”);
if (condition) True If False else
{ condition ? printf(“Odd”);
statement;
}
statement statement
else
{
statement;
}
New statement
3. Nested if
If ( a >= b)
if (condition) { if ( a >= c)
{ False True printf(“ %d
if (condition) a>=b
is
{ maximum”,
b>= c True a); else
statement;} False True a>=c printf(“ %d
False
else is
{ statement;} c is b is c is a is maximum”,
max max max max c);
} }
else else
{ {
if (condition) if ( b >= c)
{ printf(“ %d
is
statement; } maximum”,
else b); else
{ statement; } printf(“ %d
is
} maximum”,
c);
}

4. Sample program- to check whether a number is within range.

Step 1: Writing Step 2 : Draw the flowchart Step 3 : Writing Program


the Algorithm

start
/* Program to check range */
1. Start
2. Accept the number #include
3. Check if number <stdio.h>
is within range Read main( )
4. if true numbe { /* variable
r
print “Number declarations */ int n;
is within range int llimit=50, ulimit = 100;
“ otherwise /* prompting and accepting
False
print “number is input */ printf(“Enter the
If(n in range)
out of range”. number”); scanf(“%d”,&n);
5. Stop if(n>=llimit && n <= ulimit)
True printf(“Number is within
range”);
else
Number is
within range
printf(“Number is out of
range”);
}
Number is out
of range

stop
1. Execute the following program for five different values and fill in the adjoining
table

main() n output
{
int n;
printf(“Enter no.”);
scanf(“%d”,&
n); if(n%
==0)
printf(“divisible)
; else
printf(“not divisible”);
}
2. Type the above sample program 4 and execute it for the following values.

n Output
message
50
10
0
65

3. Using the sample code 3 above write the complete program to find the
maximum of three numbers and execute it for different set of values.

Instructor should fill in the blanks with appropriate values.

Signature of the instructor Date / /

Set A: Apply all the three program development steps for the following examples.
1. Write a program to accept an integer and check if it is even or odd.
2. Write a program to accept three numbers and check whether the first is
between the other two numbers. Ex: Input 20 10 30. Output: 20 is between
10 and 30
3. Accept a character as input and check whether the character is a digit.
(Check if it is in the range ‘0’ to ‘9’ both inclusive)
4. Write a program to accept a number and check if it is divisible by 5 and 7.
5. Write a program, which accepts annual basic salary of an employee and
calculates and displays the Income tax as per the following rules.
Basic: < 1,50,000 Tax = 0
1,50,000 to 3,00,000 Tax = 20%
> 3,00,000 Tax = 30%
6. Accept a lowercase character from the user and check whether the character
is a vowel or consonant. (Hint: a,e,i,o,u are vowels)

Signature of the instructor Date / /


Set B: Apply all the three program development steps for the following examples.
1. Write a program to check whether given character is a digit or a character in
lowercase or uppercase alphabet. (Hint ASCII value of digit is between 48 to 58
and Lowercase characters have ASCII values in the range of 97 to122,
uppercase is between 65 and 90)
2. Accept the time as hour, minute and seconds and check whether the time is
valid. (Hint: 0<=hour<24, 0<=minute <60, 0<=second <60)
3. Accept any year as input through the keyboard. Write a program to check whether
the year is a leap year or not. (Hint leap year is divisible by 4 and not by 100 or
divisible by 400)
4. Accept three sides of triangle as input, and print whether the triangle is valid
or not. (Hint: The triangle is valid if the sum of each of the two sides is greater
than the third side).
5. Accept the x and y coordinate of a point and find the quadrant in which the point lies.
6. Write a program to calculate the roots of a quadratic equation. Consider
all possible cases.
7. Accept the cost price and selling price from the keyboard. Find out if the seller
has made a profit or loss and display how much profit or loss has been made.

Signature of the instructor Date / /

Set C: Write programs to solve the following problems

1. Write a program to accept marks for three subjects and find the total
marks secured , average and also display the class obtained. (Class I –
above %, class II – % to
_%, pass class – _% to _% and fail otherwise)
2. Write a program to accept quantity and rate for three items, compute the
total sales amount, Also compute and print the discount as follows: (amount
> 20% discount,
amountbetween to _ _ 15% discount, amount between – to _ 8%
discount)
3. A library charges a fine for every book returned late. Accept the number of
days the member is late, compute and print the fine as follows:(less than five
days Rs fine, for 6 to 10 days Rs. fine and above 10 days Rs. _ fine )

Instructor should fill in the blanks with appropriate values.

Signature of the instructor Date / /

Assignment Evaluation Signature


0: Not done 2: Late Complete 4: Complete

1: Incomplete 3: Needs 5: Well Done


improvement
Exercise 4 Start Date / /

To demonstrate decision making statements (switch case)

You should read following topics before starting this exercise


1. Different types of decision-making statements available in C.
2. Syntax for switch case statements.

The control statement that allows us to make a decision from the number of
choices is called a switch-case statement. It is a multi-way decision making
statement.

1. Usage of switch statement

Statement Syntax Flowchart Example


switch(expression) switch (color)
{ start {
case value1: block1; case ’r’ :
break; True
case ’R’ :
case value2: case 1 Block 1 printf
block2; (“RED”);
break; False break;
. case ’g’ :
True
. case ’G’ :
case 2 Block 2
. printf
default : default (“GREEN”);
block; False break;
break; True case ’b’ :
} case 3 Block 3 case ’B’ :
printf
False (“BLUE”);
break;
True default :
case 4 Block 4
printf
(“INVALID
False COLOR”);
}
Default Block

stop
2. The switch statement is used in writing menu driven programs where a menu
displays several options and the user gives the choice by typing a character or
number. A Sample program to display the selected option from a menu is given
below.

Step 1: Step 2: Draw the flowchart Step 3: Writing Program


Writing the
Algorithm

1. Start /* Program using switch case


and
2. Display the start menu */
menu options
3. Read choice #include <stdio.h>
4. Execute Displa main( )
statement y { /* variable declarations */
block Option int choice;
depending s /* Displaying the Menu */
on choice printf(“\n 1. Option 1\n”);
5. Stop printf(“ 2. Option 2\n”);
Read choice
printf(“ 3. Option 3\n”);
printf(“Enter your choice”);
Statement 1 scanf(“%d”,&choice);
switch(choice)
True {
case 1
case 1:
False
printf(“Option 1 is selected”);
Statement 2 break;
True case 2:
case 2 printf(“Option 2 is selected”);
break;
False case 3:
Statement 3
True printf(“Option 3 is selected”);
case 3 break;
default:
} printf(“Invalid choice”);
False True
}
Default statement

stop

1. Write the program that accepts a char–type variable called color and displays appropriate
message using the sample code 1 above. Execute the program for various character
values and fill in the following table. Modify the program to include all rainbow
colours

Input character Output Message


V
I
B
G
R

Signature of the instructor Date / /


Set A: Apply all the three program development steps for the following examples.

1. Accept a single digit from the user and display it in words. For example, if
digit entered is 9, display Nine.
2. Write a program, which accepts two integers and an operator as a
character (+ - * /), performs the corresponding operation and displays the
result.
3. Accept two numbers in variables x and y from the user and perform
the following operations

Options Actions
1. Equality Check if x is equal to y
2. Less Than Check if x is less than y
3. Quotient and Divide x by y and display the quotient and
Remainder remainder
4. Range Accept a number and check if it lies between
x and y (both inclusive)
5. Swap Interchange x and y

Signature of the instructor Date / /

Set B: Apply all the three program development steps for the following examples.
1. Accept radius from the user and write a program having menu with the following
options and corresponding actions

Options Actions
1. Area of Circle Compute area of circle and print
2. Circumference of Compute Circumference of circle and print
Circle
3. Volume of Sphere Compute Volume of Sphere and print
2. Write a program having a menu with the following options and corresponding
actions

Options Actions
1. Area of square Accept length ,Compute area of square and print
2. Area of Rectangle Accept length and breadth, Compute area of
rectangle
and print
3. Area of triangle Accept base and height , Compute area of triangle
and
print

Signature of the instructor Date / /


Set C: Write a program to solve the following problems

1. Accept the three positive integers for date from the user (day, month and
year) and check whether the date is valid or invalid. Run your program for the
following dates and fill the table. (Hint: For valid date 1<=month<=12,1<= day
<=no-of-days where no-of-days is 30 in case of months 4, 6,9 and 11. 31 in case
of months 1,3,5,7,8,10 and 12. In case of month 2 no-of-days is 28 or 29
depending on year is leap or not)

Date Outpu
t
12-10-
1984
32-10-
1920
10-13-
1984
29-2-1984
29-2-2003
29-2-1900

2. Write a program having menu that has three options - add, subtract or multiply
two fractions. The two fractions and the options are taken as input and the
result is displayed as output. Each fraction is read as two integers, numerator
and denominator.

Instructor should fill in the blanks with appropriate values.

Signature of the instructor Date / /

Assignment Evaluation Signature


0: Not done 2: Late Complete 4: Complete

1: Incomplete 3: Needs 5: Well Done


improvement
Exercise 5 Start Date / /

To demonstrate use of simple loops.

You should read following topics before starting this exercise


1. Different types of loop structures in C.
2. Syntax and usage of these statements.

We need to perform certain actions repeatedly for a fixed number of times or till
some condition holds true. These repetitive operations are done using loop control
statements. The types of loop structures supported in C are
1. while statement
2. do-while statement
3. for statement

Sr. Statement Syntax Flowchart Example


No
1. while statement /* accept a
number*/
while (condition) Test scanf(“%d”, &n);
{ Condition
/* if not a single
statement 1; False
digit */ while ( n >
True
statement 2; 9)
. Loop Body
{
.
/* remove last
} digit n = n /10;
}
2. do-while statement /*initialize sum*/
sum =0;
do Loop Body do
{ {/* Get a number */
statement 1; printf( “ give number”};
True
statement 2; scanf(“%d”,&n);
Test
. Conditio
/* add number to sum*/
. n sum=sum+n;
} while (condition); } while ( n>0);
False
printf ( “sum is %d”,
sum);
3. for statement /* display first 10
multiples of 2 */
for(expr1; expr2; expr1 for( i=1; i <= 10; i++)
expr3) {
{ printf (“2 X %d = %d\
statement 1 False n”, i, 2*i);
. Test }
. expr2

} True
expr1 =
initialization
Loop
expression
expr2 = loop
condition expr3 = Body
alteration
expression which Expr3
alters the loop
variable

Note: Usually the for loop is used when the statements have to executed for a fixed
number of times. The while loop is used when the statements have to be executed as
long as some condition is true and the do-while loop is used when we want to
execute statements atleast once (example: menu driven programs)

3. Sample program- to print sum of 1+2+3+…..n.

Step 1: Writing Step 2: Draw the flowchart Step 3: Writing Program


the Algorithm
1. Start /* Program to calculate
2. Initialize sum start sum of numbers */
to 0.
3. Accept n. Sum = #include
4. Comput <stdio.h>
e main( )
0 Read
sum=sum { /* variable
+n declarations */ int sum
5. Decrement n n = 0, n;
by 1 printf(“enter the value of
6. if n > 0 n : “); scanf(“%d”,&n);
go to step 4 Compute while (n>0)
7. Display value Sum=sum {
+n
of sum. sum = sum +
8. Stop n; n--;
}
True printf(“\n The sum of numbers
n>0
is
%d”, sum);
False
}

Print
value of
sum

stop
4. Sample program- To read characters till EOF (Ctrl+Z) and count the total number
of characters entered.

Step 1 : Step 2 : Draw the flowchart Step 3 : Writing Program


Writing the
Algorithm
1. Start /* Program to count number of
2. Initialize start characters
count to 0. */
3. Accept ch. count = 0
4. If ch !=EOF #include
Count = <stdio.h>
Read ch
count main( )
+1 {
Else char ch;
Go to step 6 int count=0;
5. Go to step 3 True Ch=EOF while((ch=getchar())!=EOF)
7. Display value False
count++;
of sum.
8. Stop Count = count+1
printf(“Total characters = %d”,
count);
}

Print count

stop

1. Write a program that accepts a number and prints its first digit. Refer sample
code 1 given above. Execute the program for different values.
2. Write a program that accepts numbers continuously as long as the number is
positive and prints the sum of the numbers read. Refer sample code 2 given
above. Execute the program for different values.
3. Write a program to accept n and display its multiplication table. Refer to
sample code 3 given above.
4. Type the sample program to print sum of first n numbers and execute the
program for different values of n.
5. Write a program to accept characters till the user enters EOF and count number
of times ‘a’ is entered. Refer to sample program 5 given above.

Signature of the instructor Date / /


Set A . Apply all the three program development steps for the following examples.
1. Write a program to accept an integer n and display all even numbers upto n.
2. Accept two integers x and y and calculate the sum of all integers between x
and y (both inclusive)
3. Write a program to accept two integers x and n and compute xn
4. Write a program to accept an integer and check if it is prime or not.
5. Write a program to accept an integer and count the number of digits in the number.
6. Write a program to accept an integer and reverse the number. Example: Input:
546, Output 645.
7. Write a program to accept a character, an integer n and display the next n
characters.

Signature of the instructor Date / /

Set B. Apply all the three program development steps for the following examples.
1. Write a program to display the first n Fibonacci numbers. (1 1 2 3 5 ……)
2. Write a program to accept real number x and integer n and calculate the sum of
first n terms of the series x+ 3x+5x+7x+…
3. Write a program to accept real number x and integer n and calculate the sum of first
n terms
1 2 3
of the series
x + x2 + x3 +
4. Write a program to accept characters till the user enters EOF and count
number of alphabets and digits entered. Refer to sample program 5
given above.
5. Write a program, which accepts a number n and displays each digit in
words. Example: 6702 Output = Six-Seven-Zero-Two. (Hint: Reverse the
number and use a switch statement)

Signature of the instructor Date / /

Set C. Write C programs to solve the following problems

1. Write a program to accept characters from the user till the user enters * and
count the number of characters, words and lines entered by the user. (Hint:
Use a flag to count words. Consider delimiters like \n \t , ; . and space for
counting words)
2. Write a program which accepts a number and checks if the number is a
palindrome (Hint number = reverse of number)
Example: number = 3472 Output: It is not a palindrome number = 262, Output
: It is a palindrome
3. A train leaves station A at 4.00 a.m and travels at 80kmph. After every 30
minutes, it reaches a station where it halts for 10 minutes. It reaches its
final destination B at 1.00
p.m. Display a table showing its arrival and departure time at every
intermediate station. Also calculate the total distance between A and B.
4. A task takes 4 ½ hours to complete. Two workers, A and B start working on it
and take turns alternately. A works for 25 minutes at a time and is paid Rs 50,
B works for 75 minutes at a time and is paid Rs. 150. Display the total number
of turns taken by A and B, calculate their total amounts and also the total cost
of the task.

Signature of the instructor Date / /

Assignment Evaluation Signature


0: Not done 2: Late Complete 4: Complete

1: Incomplete 3: Needs 5: Well Done


improvement
Exercise 6 Start Date / /

To demonstrate use of nested loops

In the previous exercise, you used while, do-while and for loops. You should read
following topics before starting this exercise
1. Different types of loop structures in C.
2. Syntax for these statements.
3. Usage of each loop structure

Nested loop means a loop that is contained within another loop. Nesting can be done
upto any levels. However the inner loop has to be completely enclosed in the outer
loop. No overlapping of loops is allowed.

Sr. Format Sample Program


No
1. Nested for loop /* Program to display triangle of
numbers*/
for(exp1; exp2 ; exp3) #include <stdio.h>
{ …………………… void main( )
for(exp11; exp12 ; exp13) {
{ …………………… int n , line_number , number;
} printf(“How many lines: ”);
……………………. scanf(“%d”,&n);
} for(line_number =1 ;line_number
<=n;
line_number++ )
{
for(number = 1; number <=
line_number;
number++)
printf (“%d\t”, number);
printf (“\n”);
}
}

2. Nested while loop / do while loop /* Program to calculate sum of digits


till
sum is a single digit number */
while(condition1)
{ …………………… #include <stdio.h>
while(condition2) void main( )
{ …………………… {
} int n , sum;
……………………. printf(“Give any number ”);
} scanf(“%d”,&n);
do
do {
{ …………………… sum =0;
while(condition1) printf(“%d --->”,n);
{ ……………….. while ( n>0)
} { sum +=n%10;
………………. n= n/10;
} while (condition2); }
n=sum;
} while( n >9);
printf ( “ %d” ,
n);
}

Note: It is possible to nest any loop within another. For example, we can have a for loop
inside a while or do while or a while loop inside a for.

1. The Sample program 1 displays n lines of the following triangle. Type the
program and execute it for different values of n.
1
1 2
1 2 3
1 2 3 4
2. Modify the sample program 1 to display n lines of the Floyd’s triangle as follows
(here n=4). 1
2 3
4 5 6
7 8 9 10
3. The sample program 2 computes the sum of digits of a number and the process
is repeated till the number reduces to a single digit number. Type the
program and execute it for different values of n and give the output

Input number Output


6534
67
8
567

Signature of the instructor Date / /

Set A . Write C programs for the following problems.


1. Write a program to display all prime numbers between _ and _ _.
2. Write a program to display multiplication tables from to having n multiples each.
The output should be displayed in a tabular format. For example, the
multiplication tables of 2 to 9 having 10 multiples each is shown below.
21 =2 3  1 = 3 ………….9  1 = 9
22 =4 3  2 = 6…………..9  2 = 18
…………. ………….
2  10 = 20 3  10 = 30………..9  10 = 90
3. Modify the sample program 1 to display n lines as follows
(here n=4). A B C D
E F G
H I
J
Signature of the instructor Date / /

Set B. Write C programs for the following problems.


1. Write a program to display all Armstrong numbers between 1 and 500. (An
Armstrong number is a number such that the sum of cube of digits = number
itself Ex. 153 = 1*1*1 + 5*5*5 + 3*3*3
2. Accept characters till the user enters EOF and count the number of lines
entered. Also display the length of the longest line. (Hint: A line ends when
the character is \n)
3. Display all perfect numbers below 500. [A perfect number is a number, such
that the sum of its factors is equal to the number itself]. Example: 6 (1 + 2 +
3), 28 (1+2+4+7+14)

Signature of the instructor Date / /

Set C. Write C programs to solve the following problems


1. A company has four branches, one in each zone: North, South, East and West.
For each of these branches, it collects sales information once every quarter (four
months) and calculates the average sales for each zone. Write a program that
accepts sales details for each quarter in the four branches and calculate the
average sales of each branch.
2. A polynomial in one variable is of the form a0 + a1x + a2x2 + …. For
example, 6 - 9x + 2x5. Write a program to calculate the value of a polynomial.
Accept the number of terms n , the value of x, and n+1coefficients.
3. The temperature of a city varies according to seasons. There are four seasons –
spring, summer, Monsoon and winter. The temperature ranges are: Spring (15-
25 degrees), Summer (25-40 degrees), Monsoon (20-35 degrees), Winter (5-20
degrees). Accept weekly temperatures (12 weeks per season) for each season,
check if they are in the correct range and calculate the average temperature for
each season.

Signature of the instructor Date / /

Assignment Evaluation Signature


0: Not done 2: Late Complete 4: Complete

1: Incomplete 3: Needs 5: Well Done


improvement
Exercise 7 Start Date / /

To demonstrate menu driven programs and use of standard library functions

You should read following topics before starting this exercise


1. Use of switch statement to create menus as in exercise 3
2. Use of while and do while loops as in exercise 4

A function is a named sub-module of a program, which performs a specific, well-


defined task. It can accept information from the calling function in the form of
arguments and return only 1 value. C provides a rich library of standard functions.
We will explore some such function libraries and use these functions in our
programs.

ctype.h : contains function prototypes for performing various operations on


characters. Some commonly used functions are listed below.

Function Name Purpose Example


isalpha Check whether a character is a alphabet if (isalpha(ch))
isalnum Check whether a character is alphanumeric if (isalnum(ch))
isdigit Check whether a character is a digit if (isdigit(ch))
isspace Check whether a character is a space if (isspace(ch))
ispunct Check whether a character is a punctuation if (ispunct(ch))
symbol
isupper Check whether a character is uppercase if (isupper(ch))
alphabet
islower Check whether a character is lowercase if (isupper(ch))
alphabet
toupper Converts a character to uppercase ch = toupper(ch)
tolower Converts a character to lowercase ch = tolower(ch)

math.h : This contains function prototypes for performing various mathematical


operations on numeric data. Some commonly used functions are listed below.

Function Name Purpose Example


cos cosine a*a+b*b –
2*a*b*cos(abangle)
exp(double x) exponential function, computes exp( x)
ex
log natural logarithm c= log(x)
log10 base-10 logarithm y=log10(x)
pow(x,y) compute a value taken y = 3*pow( x , 10)
to an exponent, xy
sin sine z= sin(x) / x
sqrt square root delta=sqrt(b*b – 4*a*c)

Note: If you want to use any of the above functions you must include the library
for example #include <ctype.h>
#include <math.h>
In case of math library , it needs to be linked to your program. You have to compile
the program as follows
$ cc filename -lm
A program that does multiple tasks, provides a menu from which user can choose the
appropriate task to be performed. The menu should appear again when the task is
completed so that the user can choose another task. This process continues till the
user decides to quit. A menu driven program can be written using a combination of
do-while loop containing a switch statement. One of the options provided in a menu
driven program is to exit the program.

Statement Syntax Flowchart Example


do start ch =
{ getchar(); do
display {
menu; Display menu p r i n t f ( “ \ n 1 : ISUP
accept PER ” ) ; printf(“\ n 2 :
choice;
Accept choice ISLOW ER ” ) ; printf(“\ n
switch(choic
3 : ISDIGIT “);
e)
{ printf(“\n4:EXIT”);
case True
case 1
value1: printf(“ Enter yo ur choice
block1; block1 False :”);
scanf(“%d”,&choic
True
break; case 2
e);
block
case
value2: switch(choice)
block2; 2 False
{
case 1 : if ( isupper( ch))
break; default block
. printf(“Uppercas
. e”);break;
. False
choice=exit case 2 : if ( is lower( ch))
default :
default block;
} Tru printf(“Lowercas
}while(choice e”);break;
e stop case3:if(isdigit(c
!= exit);
h))
printf(“ Digit”);
break ;
}
} wh i l e ( c h o i c e ! = 4 ) ;

1. Write a menu driven program to perform the following operations on a character type
variable.
i. Check if it is an alphabet
ii. Check if it is a digit.
iii. Check if it is lowercase.
iv. Check if it is uppercase.
v. Convert it to uppercase.
vi. Convert it to lowercase.
Refer to the sample code given above and use standard functions from ctype.h

Set A . Write C programs for the following problems


1. Write a program, which accepts a character from the user and checks if it is an
alphabet, digit or punctuation symbol. If it is an alphabet, check if it is
uppercase or lowercase and then change the case.
2. Write a menu driven program to perform the following operations till the user
selects Exit.
Accept appropriate data for each option. Use standard library functions from math.h
i. Sine ii. Cosine iii. log iv. ex v. Square Root vi. Exit
3. Accept two complex numbers from the user (real part, imaginary part). Write a
menu driven program to perform the following operations till the user selects
Exit.
i. ADD ii. SUBTRACT iii. MULTIPLY iv.

EXIT Signature of the instructor Date / /


Set B . Write C programs for the following problems
1. Accept x and y coordinates of two points and write a menu driven program to
perform the following operations till the user selects Exit.
i. Distance between points.
ii. Slope of line between the points.
iii. Check whether they lie in the same quadrant.
iv. EXIT
(Hint: Use formula m = (y2-y1)/(x2-x1) to calculate slope of line.)
2. Write a simple menu driven program for a shop, which sells the following items:
The user selects items using a menu. For every item selected, ask the quantity. If the
quantity of any item is more than 10, give a discount of %. When the user
selects Exit, display the total amount.

Item Price

Instructor should fill in the blanks with appropriate values.

Signature of the instructor Date / /

Set C . Write C programs for the following problems

1. Write a program to calculate the total price for a picnic lunch that a user is
purchasing for her group of friends. She is first asked to enter a budget for the
lunch. She has the option of buying apples, cake, and bread. Set the price per kg
of apples, price per cake, and price per loaf of bread in constant variables. Use a
menu to ask the user what item and how much of each item she would like to
purchase. Keep calculating the total of the items purchased. After purchase of an
item, display the remaining amount. Exit the menu if the total has exceeded the
budget. In addition, provide an option that allows the user to exit the purchasing
loop at any time.

Signature of the instructor Date / /

Assignment Evaluation Signature


0: Not done 2: Late Complete 4: Complete

1: Incomplete 3: Needs 5: Well Done


improvement
Exercise 8 Start Date / /

To demonstrate writing C programs in modular way (use of user defined functions)

You should read following topics before starting this exercise


1. Declaring and Defining a function
2. Function call
3. Passing parameters to a function
4. Function returning a value

You have already used standard library functions. C allows to write and use user
defined functions. Every program has a function named main. In main you can call
some functions which in turn can call other functions.

The following table gives the syntax required to write and use functions
Sr. Actions involving Syntax Example
No functions
1. Function declaration returntype function(type void display();
arg1, type arg2 … ); int sum(int x, int y);

2. Function definition returntype function(type float calcarea (float r)


arg1, type arg2 … ) {
{ float area = Pi
/* statements*/ *r*r ; return
} area;
}
3. Function call function(arguments); display();
variable = ans = calcarea(radius);
function(arguments);

1. Sample code

The program given below calculates the area of a circle using a function and uses
this function to calculate the area of a cylinder using another function.

/* Program to calculate area of circle and cylinder using function */

#include
<stdio.h> void
main()
{
float areacircle (float r);
float areacylinder(float r,
int h); float area, r;
printf(“\n Enter
Radius: “);
scanf(“%f”,&r);

area=areacircle(r);
printf(“\n Area of circle =%6.2f”, area);
scanf(“%d”,&h);
area=areacylinder(r,h);
printf(“\n Area of cylinder =%6.2f”, area);
}

float areacircle (float r)


{
const float
pi=3.142;
return(pi * r*r );
}
float areacylinder (float r, int h)
{
return 2*areacircle(r)*h;
2. Sample code

The function iswhitespace returns 1 if its character parameter is a space, tab or


newline character. The program accepts characters till the user enters EOF and
counts the number of white spaces.

/* Program to count whitespaces using function */

#include
<stdio.h> void
main()
{
int iswhitespace (char
ch); char ch;
int count=0;

printf(“\n Enter the characters. Type CTRL +Z to terminate: “);


while((ch=getchar())!=EOF)
if(iswhitespace(ch))
count++;
printf(“\n The total number of white spaces =%d”, count);
}
int iswhitespace (char ch)
{
switch(ch)
{
case ‘ ‘:
case ‘\t’ :
case ‘\n’ :
return 1;
default : return
0;

1. Type the program given in sample code 1 above and execute the program.
Comment function declarations and note down the type of error and the
error messages received. Add another function to calculate the volume of
sphere and display it.
2. Type the program given in sample code 2 above and execute the
program. Comment function declaration and note down the type of error and
the error messages received. Modify the function such that it returns 1 if
the character is a vowel. Also count the total number of vowels entered.
Set A . Write C programs for the following problems
1. Write a function isEven, which accepts an integer as parameter and returns 1
if the number is even, and 0 otherwise. Use this function in main to accept n
numbers and ckeck if they are even or odd.
2. Write a function, which accepts a character and integer n as parameter and
displays the next n characters.
3. Write a function, which accepts a character and integer n as parameter and
displays the next n characters.

Signature of the instructor Date / /

Set B . Write C programs for the following problems


1. Write a function isPrime, which accepts an integer as parameter and returns 1
if the number is prime and 0 otherwise. Use this function in main to display the
first 10 prime numbers.
2. Write a function that accepts a character as parameter and returns 1 if it is an
alphabet, 2 if it is a digit and 3 if it is a special symbol. In main, accept
characters till the user enters EOF and use the function to count the total
number of alphabets, digits and special symbols entered.
3. Write a function power, which calculates x y. Write another function, which
calculates n! Using for loop. Use these functions to calculate the sum of first n
terms of the Taylor series:
x3 + x5
sin(x) = + ……
x- 3! 5!
Signature of the instructor Date / /

Set C . Write C programs for the following problems


1. Write a menu driven program to perform the following operations using the
Taylor series. Accept suitable data for each option. Write separate functions
for each option.
a. ex

b.sin(x)

c. cos (x)

Define separate functions to calculate xy and n! and use them in each function.

Signature of the instructor Date / /

Assignment Evaluation Signature


0: Not done 2: Late Complete 4: Complete

1: Incomplete 3: Needs 5: Well Done


improvement
Exercise 9 Start Date / /

To demonstrate Recursion.

You should read the following topics before starting this exercise
1. Recursive definition
2. Declaring and defining a function
3. How to call a function
4. How to pass parameters to a function

Recursion is a process by which a function calls itself either directly or indirectly. The
points to be remembered while writing recursive functions
i. Each time the function is called recursively it must be closer to the solution.
ii. There must be some terminating condition, which will stop recursion.
iii. Usually the function contains an if –else branching statement where one
branch makes recursive call while other branch has non-recursive
terminating condition
Expressions having recursive definitions can be easily converted into recursive functions

Sr. Recursive definition Recursive Function Sample program


No
1. The recursive long int factorial (int n) #include
definition for factorial { <stdio.h>
is given below: If (n==0)||(n==1)) main()
/* terminating {
n!= 1 if n = 0 or condition */ int num;
1 return(1); /* function
= n * (n-1)! if n > else declaration */ long
1 return(n* int factorial(int n);
factorial(n- printf(“\n enter the
1)); number:”);
/* recursive call */ scanf(“%d”,&num);
} printf(“\n The
factorial of
%d is
%ld”,num,factorial(num)
);
}
/* function code*/
2. The recursive long int nCr( int n, int r) #include <stdio.h>
definition for nCr ( no { if(n==r || r==0) /* function
of combinations of r /* terminating code*/ main()
objects out of n condition */ {
objects) is as follows return(1); int n, r;
nCn = 1 else printf(“\n enter the
nC0 = 1 return ( nCr(n- total number of
nCr = n-1Cr + nCr-1 1,r) + nCr(n, r-1)); objects:”);
/* recursive call */ scanf(“%d”,&n);
} printf(“\n enter the
number of objects to
be selected”);
scanf(“%d”,&r);
printf(“\n The value
%dC%d is
%ld”,n, r,
nCr(n,r));
}
1. Write the sample program 1 given above and execute the program. Modify
the program to define a global integer variable count and increment it in
factorial function. Add a printf statement in main function for variable count.
Execute the program for different values and fill in the following table.

Sr. No. num factorial Count


1. 0
2 1
3 5
4
5

2. Write the sample program 2 given above and execute the program for different
values of n and r. Modify the program to define a global integer variable count
and increment it in nCr function. Add a print statement in main function for
variable count. Execute the program for different values and fill in the following
table

Sr. No. n r nCr Count


1. 5 0
2 5 5
3 5 2
4 5
5

Instructor should fill in the blanks with appropriate values.

Signature of the instructor Date / /

Set A . Write C programs for the following problems

1. Write a recursive C function to calculate the sum of digits of a number. Use


this function in main to accept a number and print sum of its digits.
2. Write a recursive C function to calculate the GCD of two numbers. Use this
function in main. The GCD is calculated as :
gcd(a,b) = a if b = 0
= gcd (b, a mod b) otherwise
3. Write a recursive function for the following recursive definition. Use this
function in main to display the first 10 numbers of the following series
an = 3 if n = 1 or 2
= 2* an-1 + 3*an-2 if n > 2
4. Write a recursive C function to calculate xy. (Do not use standard library function)
Signature of the instructor Date
/ /
Set B . Write C programs for the following problems
1. Write a recursive function to calculate the nth Fibonacci number. Use this
function in main to display the first n Fibonacci numbers. The recursive
definition of nth Fibonacci number is as follows:
fib(n) = 1 if n = 1 or 2
= fib(n-2) + fib(n-1) if n>2
2. Write a recursive function to calculate the sum of digits of a number till you get
a single digit number. Example: 961 -> 16 -> 5. (Note: Do not use a loop)
3. Write a recursive C function to print the digits of a number in reverse order. Use
this function in main to accept a number and print the digits in reverse order
separated by tab.
Example 3456
6543
(Hint: Recursiveprint(n) = print n if n is single digit number
= print n % 10 + tab + Recursiveprint( n/10)

Signature of the instructor Date / /

Set C . Write C programs for the following problems


1. The “Towers of Hanoi” problem: The objective is to move a set of disks arranged
in increasing sizes from top to bottom from the source pole to a destination
pole such that they are in the same order as before using only one intermediate
pole subject to the condition that
i. Only one disk can be moved at a time
ii. A bigger disk cannot be placed on a smaller disk.
Write a recursive function which displays all the steps to move n disks from A to C.

1
disks 2
3
4
5

Sourc
e Intermedia Destinati
Needl te needle on Needle
e (A) (B) (C)

Signature of the instructor Date / /

Assignment Evaluation Signature


0: Not done 2: Late Complete 4: Complete

1: Incomplete 3: Needs improvement 5: Well Done


Exercise 10 Start Date / /

To demonstrate use of 1-D arrays and functions.

You should read the following topics before starting this exercise
1. What are arrays and how to declare an array?
2. How to enter data in to array and access the elements of an array.
3. How to initialize an array and how to check the bounds of an array?
4. How to pass an array to a function

An array is a collection of data items of the same data type referred to by a common
name. Each element of the array is accessed by an index or subscript. Hence, it is
also called a subscripted variable.

Actions involving syntax Example


arrays
Declaration of array data-type array_name[size]; int temperature[10];
float pressure[20];
Initialization of array data-type array_name[]={element1, int
element2, ……, element n}; marks[]={45,57,87,20,90}
;
data-type marks[3] refers to the
array_name[size]={element-1, fourth element which
element-2, ……, element- equals 20
size};
int count[3]={4,2,9};
You cannot give more count[2] is the last
number of initial values than element 9 while 4 is
the array size. If count[0]
you specify less values, the
remaining will be initialized
to 0.
Accessing elements The array index begins from 0 Value = marks[3];
of an array (zero) To access an array This refers to the 4th
element, we need to refer to it element in the array
as array_name[index].

Entering data into for (i=0; i<=9; i++)


an array. scanf(“%d”,
&marks[i]);
Printing the data for(i=0; i<=9; i++)
from an array printf(“%d”,
marks[i]);
Arrays and function We can pass an array to a /* Passing the whole
function using two methods. array*/ void modify(int
1. Pass the array element a[5])
by element {
2. Pass the entire array to int i;
the function for(i=0; i<5 ; i++)
a[i] = i;
}
Sample program to find the largest element of an array

/* Program to find largest number from array */

#include<stdio
.h> int main()
{
int arr[20]; int n;
void accept(int a[20], int
n); void display(int
a[20], int n); int
maximum(int a[20], int
n);

printf(”How many
numbers :”); scanf(“%d”,
&n); accept(arr,n);
display(arr,n);
printf(“The maximum is :%d” , maximum(arr,n));
}

void accept(int a[20], int n)


{
int i;
for(i=0; i<n ; i++)
scanf(“%d”, &a[i]);
}

void display(int a[20], int n)


{
int i;
for(i=0; i<n ; i++)
printf(“%d\t”, a[i]);
}
int maximum(int a[20], int n)
{
int i, max = a[0];

for(i=1; i<n ; i++)


if(a[i] > max)
max =

1. Write a program to accept n numbers in an array and display the largest and
smallest number. Using these values, calculate the range of elements in the array.
Refer to the sample code given above and make appropriate modifications.
2. Write a program to accept n numbers in an array and calculate the average.
Refer to the sample code given above and make appropriate modifications.

Signature of the instructor Date / /


Set A. Write programs to solve the following problems

1. Write a program to accept n numbers in the range of 1 to 25 and count the


frequency of occurrence of each number.
2. Write a function for Linear Search, which accepts an array of n elements and a
key as parameters and returns the position of key in the array and -1 if the key
is not found. Accept n numbers from the user, store them in an array. Accept the
key to be searched and search it using this function. Display appropriate
messages.
3. Write a function, which accepts an integer array and an integer as parameters
and counts the occurrences of the number in the array.
4. Write a program to accept n numbers and store all prime numbers in an array
called prime. Display this array.

Signature of the instructor Date / /

Set B. Write programs to solve the following problems

1. Write a program to accept n numbers from the user and store them in an array
such that the elements are in the sorted order. Display the array. Write
separate functions to accept and display the array. (Hint: Insert every number
in its correct position in the array)
2. Write a function to sort an array of n integers using Bubble sort method.
Accept n numbers from the user, store them in an array and sort them using
this function. Display the sorted array.
3. Write a program to accept a decimal number and convert it to binary, octal
and hexadecimal. Write separate functions.
4. Write a program to find the union and intersection of the two sets of integers
(store it in two arrays).
5. Write a program to remove all duplicate elements from an array.

Signature of the instructor Date / /


Set C. Write programs to solve the following problems

1. Write a program to merge two sorted arrays into a third array such that the
third array is also in the sorted order.

a1 10 25 90
a2 9 16 22 2 10
6
0
a3 9 10 16 2 25 26 90 100
2

2. Write a program to accept characters from the user till the user enters EOF and
calculate the frequency count of every alphabet. Display the alphabets and their
count.
Input: THIS IS A SAMPLE INPUT
Output: Character Count
T 2
H 1
I 3
…….

3. Write a recursive function for Binary Search, which accepts an array of n


elements and a key as parameters and returns the position of key in the array
and -1 if the key is not found. Accept n numbers from the user, store them in
an array and sort the array. Accept the key to be searched and search it using
this function. Display appropriate messages

Signature of the instructor Date / /

Assignment Evaluation Signature


0: Not done 2: Late Complete 4: Complete

1: Incomplete 3: Needs 5: Well Done


improvement
Exercise 11 Start Date / /

To demonstrate use of 2-D arrays and functions.

You should read the following topics before starting this exercise
1. How to declare and initialize two-dimensional array
2. Accessing elements
3. Usage of two dimensional arrays

Actions involving syntax Example


2-D arrays
Declaration of data-type array_name[size][size]; int mat[10]
2-D array [10]; float
sales[4][10];
Initialization of data-type array_name[rows][cols]={ int num[][2] = {12, 34,
2-D array {elements of row 0},{ elements of 23,
row 1},…..}; 45, 56, 45};
data-type array_name[][cols]={element1, int num[3][2] = { {1,2},
element2, ……, element size}; {3,4}, {5,6}};
int num[3][2] = {
1,2,3,4, 5,6};
Accessing Accessing elements of an two- int m[3][2];
elements of dimensional array - in general, the m is declared as a two
2-D array array element is dimensional array
referred (matrix) having 3 rows
as array_name[index1] (numbered 0
[index2] where index1 is the row to 2) and 2 columns
location of and index2 is the column (numbered 0 to 1). The
location of an element in the array. first element is m[0] [0]
and the last is m [2][1].
value = m[1][1];
Entering data int mat[4][3];
into a 2-D for (i=0; i<4; i++)
array. /* outer loop for
rows */ for
(j=0;j<3; j++)
/* inner loop for
columns */
scanf(“%d”,
&mat[i][j]);
Printing the for (i=0; i<4; i++)
data from a 2- /* outer loop for rows */
D array {
for (j=0;j<3; j++)
/* inner loop for
columns */
printf(“%d\t” ,
mat[i][j]); printf(”\
n”);
}
Sample program to accept, display and print the sum of elements of each row of a matrix.

/* Program to calculate sum of rows of a matrix*/

#include<stdio
.h> int main()
{
int mat[10][10], m, n;
void display(int a[10][10], int m, int
n); void accept(int a[10][10], int m,
int n); void sumofrows(int a[10][10],
int m, int n);

printf(“How many rows and columns?


”); scanf(“%d%d”,&m, &n);

printf(“Enter the matrix


elements :”); accept(mat, m,
n);
printf(“\n The matrix
is :\n”); display(mat, m,
n);
sumofrows(mat,m,n);
}

void accept(int a[10][10], int m, int n)


{
int i,j;
for (i=0; i<m; i++) /* outer loop for
rows */ for (j=0;j<n; j++) /* inner
loop for columns */
scanf(“%d”, &a[i][j]);
}
void display(int a[10][10], int m, int n)
{
int i,j;
printf(”\nThe elements of %d by %d matrix are\
n”, m, n); for (i=0; i<m; i++) /* outer loop for
rows */
{
for (j=0;j<n; j++) /* inner loop for
columns */ printf(“%d\t” , a[i][j]);
printf(”\n”);
}
}
void somofrows(int a[10][10], int m, int n)
{
int i,j, sum;
for (i=0; i<m; i++) /* outer loop for rows */
{ sum=0’
for (j=0;j<n; j++) /* inner loop for

1. Write a program to accept, display and print the sum of elements of each row
and sum of elements of each column of a matrix. Refer to sample code given above.

Signature of the instructor Date / /


Set A . Write C programs for the following problems.
1. Write a program to accept a matrix A of size mXn and store its transpose in
matrix B. Display matrix B. Write separate functions.
2. Write a program to add and multiply two matrices. Write separate functions to
accept, display, add and multiply the matrices. Perform necessary checks before
adding and multiplying the matrices.

Signature of the instructor Date / /

Set B . Write C programs for the following problems.

1. Write a menu driven program to perform the following operations on a square


matrix. Write separate functions for each option.
a. Check if the matrix is symmetric.
b. Display the trace of the matrix (sum of diagonal elements).
c. Check if the matrix is an upper triangular matrix.

2. Write a menu driven program to perform the following operations on a square


matrix. Write separate functions for each option.
i) Check if the matrix is a lower triangular matrix.
ii) Check if it is an identity matrix.

3. Write a program to accept an mXn matrix and display an m+1 X n+1


matrix such that the m+1th row contains the sum of all elements of
corresponding row and the n+1th column contains the sum of elements of the
corresponding column.
Example:
A B
1 2 3 1 2 3 6
4 5 6 4 5 6 15
7 8 9 7 8 9 24
12 15 18 45

Signature of the instructor Date / /

Set C. Write programs to solve the following problems

1. Pascal's triangle is a geometric arrangement of the binomial coefficients in a


triangle. It is named after Blaise Pascal. Write a program to display n lines of
the triangle.

1
1 1
1 2 1
1 1 3 3
1
4 6 4 1
1 5 10 10 5 1
1 6 15 20 15 6 1
2. A magic square of order n is an arrangement of n² numbers, in a square, such that the n
numbers in all rows, all columns, and both diagonals sum to the same constant. A normal
magic square contains the integers from 1 to n². The magic constant of a magic square
depends on n and is M(n) = (n 3+n)/2. For n=3,4,5, the constants are 15, 34, 65 resp. Write a
program to generate and display a magic square of order n.

Signature of the instructor Date / /

Assignment Evaluation Signature


0: Not done 2: Late Complete 4: Complete
1: 3: Needs 5: Well Done
Incomplete improvement
Savitribai Phule Pune University

Section-II

F. Y. B.Sc. (Computer Science)


SEMESTER I

Lab Course – II
Relational Database
Management
System Assignments
Assignment Completion Sheet

Lab Course II

Advanced Relational Database Management System Assignments

Sr. Assignment Name Marks Instructor


No. (out of 5) Sign

1 Case study – ER diagram

2 Case study – ER diagram (with generalization)

3 Case study – ER diagram (with aggregation)

4 Using PostgreSQL (demo of PostgrSQL)

5 Data Definition queries (Create)

6 Data Definition queries (Alter)

7 Data Definition queries (Drop)

8 Simple queries (Select)

9 Queries with join

10 Aggregate queries (Group by and Having)

11 Nested Queries

12 Data Manipulation queries (Insert)

13 Data Manipulation queries (Delete)

14 Data Manipulation queries (Update)

Total (Out of 70)

Total (Out of 07)

This is to certify that Mr./Ms.


Has successfully completed the RDBMS course work for Lab Course II
andhas scored
Marks out of 07.

Instructor H.O. D / Coordinator

Internal Examiner External Examiner


Assignment No. 1

What is Entity RelationshipDiagram (ER-Diagram)?

ER-Diagram is a pictorial representation of data that describes how data is communicated


and related to each other. Any object, such as entities, attributes of an entity, sets of
relationship and other attributes of relationship can be characterized with the help of the
ER diagram.

Entities:

They are represented using the rectangle shape box. These rectangles are named with the
entity set they represent.

ER modeling is a top-down structure to database design that begins with identifying the
important data called entities and relationships in combination between the data that must
be characterized in the model. Then database model designers can add more details such as
the information they want to hold about the entities and relationships which are the
attributes and any constraints on the entities, relationships, and attributes. ER modeling is
an important technique for any database designer to master and forms the basis of the
methodology.

 Entity type: It is a group of objects with the same properties that are
identified by the enterprise as having an independent existence. The
basic concept of the ER model is the entity type that is used to represent
a group of ‘objects’ in the ‘real world’ with the same properties. An entity
type has an independent existence within a database.
 Entity occurrence: A uniquely identifiable object of an entitytype.

Diagrammatic Representation of Entity Types

Each entity type is shown as a rectangle labeled with the name of the entity, which is
normally a singular noun.
What is Relationship Type?

A relationship type is a set of associations between one or more participating entity


types. Each relationship type is given a name that describes its function.

Here is a diagram showing how relationships are formed in a database.

What is degree of Relationship?

The entities occupied in a particular relationship type are referred to as participants in


that relationship. The number of participants involved in a relationship type is termed as the
degree of that relationship.

In the above figured example “Branch has staff”, there is a relationship between two
participating entities. A relationship of degree two is called binary degree (relationship).

What are Attributes?

Attributes are the properties of entities that are represented by means of ellipse shaped
figures. Every elliptical figure represents one attribute and is directly connected to its
entity (which is represented as rectangle).

It is to be noted that multi-valued attributes are represented using double ellipse like this:

Relationships

Relationships are represented by diamond-shaped box. All the entities (rectangle


shaped) participating in a relationship gets connected using a line.

There are four types of relationships. These are:

 One-to-one: When only a single instance of an entity is associated


with the relationship, it is termed as ‘1:1’.
 One-to-many: When more than one instance of an entity isrelated and
linked with a relationship, it is termed as ‘1:N’.
 Many-to-one: When more than one instance of entity is linked
with the relationship, it is termed as ‘N:1’.
 Many-to-many: When more than one instance of an entity on the left and
more than one instance of an entity on the right can be linked with the
relationship, then it is termed as N:N relationship.
Set A

Suppose you are given the following requirements for a simple database for the National
Hockey League (NHL):

 the NHL has manyteams,


 each team has a name, a city, a coach, a captain, and a set ofplayers,
 each player belongs to only oneteam,
 each player has a name, a position (such as left wing or goalie), a skill level, and a set
of injury records,
 a team captain is also a player,
 a game is played between two teams (referred to as host_team and guest_team) and has
a date (such as May 11th, 1999) and a score (such as 4to 2).

Consider the case study given above and find out entities and their attributes.

Set B

Find different set of entities and their attributes for online bookstore

Assignment Evaluation
0: Not Done [ ]
1: Incomplete [ 2: Late Complete [ ]
3: Needs
] 4: Complete [ 5: WellDone [ ]
Improvement [ ]
]

Signature of Teacher
Assignment no 2

The ER model supported with additional semantic concepts is called the Enhanced Entity-
Relationship (EER) model. There are three of the most important and useful added concepts
of the EER model, namely specialization/generalization, aggregation, and composition. In this
chapter you will learn about the main two important concepts. These are:

 Generalization Aggregation

What are Generalization / Specialization?

The concept of generalization (specialization) is associated with special types of entities


known as super classes and subclasses, and the process of attribute inheritance.
Database managers begin this section by defining what super classes and subclasses are
and by examining super class/subclass relationships. The ER Model has the capability of
articulating database entities in a conceptual hierarchical manner. As the hierarchy goes up,
it generalizes the view of entities and as you go deep in the hierarchy, it will provide with
the detail of every entity included. Going up in this structure is called generalization, where
entities are associated together to represent a more generalized view. Generalization is a
bottom-up approach.

In generalization, a number of entities are accommodated together into one generalized


entity or category based on their similar characteristics. In the below mentioned figure,
whale, shark and dolphin are generalized as fish, i.e. they have been categorized as the fish.

 Super-class: An entity type that includes one or more dissimilar sub-


groupings of its occurrences that is required to be represented in a data
model.
 Sub-class: A distinct sub-grouping of occurrences of an entity type that
require to be represented in a data model.
Super-class/Subclass Relationships

Each member of a sub class is also a member of the super class i.e. the entity in the sub
class is the same entity in the super class, but has a different role. The relationship
between a super class and a sub class is one-to-one (1:1) and is termed as a
super-class/sub-class relationship.

Set A

Refer to the case studies given in assignment no 1

1. Find the relationships among all entities from setA


2. Find the relationships among all entities from setB

Assignment Evaluation
0: Not Done [ ] 1: Incomplete [ ] 2: Late Complete [ ]
3: Needs Improvement [ ] 4: Complete [ ] 5: WellDone
[]

Signature of Teacher
Assignment no.3
What is Aggregation?

A relationship represents a connection between two entity types that are conceptually at
the same level. Sometimes you may want to model a ‘has-a’, ‘is-a’ or ‘is-part-of’
relationship, in which one entity represents a larger entity (the ‘whole’) that will consist of
smaller entities (the ‘parts’). This special kind of relationship is termed as an aggregation.
Aggregation does not change the meaning of navigation and routing across the
relationship between the whole and its parts.

An example of an aggregation is the ‘Teacher’ entity following the ‘syllabus’ entity act as a
single entity in the relationship. In simple words, aggregation is a process where the relation
between two entities is treated as a single entity.

Set A

Draw an Entity-Relationship diagram for the National Hockey League (NHL):

 the NHL has many teams,


 each team has a name, a city, a coach, a captain, and a set of players,
 each player belongs to only one team,
 each player has a name, a position (such as left wing or goalie), a skill level, and a
set of injury records,
 a team captain is also a player,
 a game is played between two teams (referred to as host_team and guest_team)
and has a date (such as May 11th, 1999) and a score (such as 4 to 2).
Set B

Consider a database used to record the marks that students get in different exams of
different course offerings.
a) Construct an E-R diagram that models exams as entities, and uses a ternary relationship,
for the above database.

b) Construct an alternative E-R diagram that uses only a binary relationship between
students and course-offerings. Make sure that only one relationship exists between a
particular student and course- offering pair, yet you can represent the marks that a
student gets in differentexams of a course offering.

Assignment Evaluation
0: Not Done [ ] 1: Incomplete [ 2: Late Complete [ ]
3: Needs ] 4: Complete [ 5: WellDone [ ]
Improvement [ ]
]

Signature of Teacher
Assignment no.4 Using
Postgresql (Demo of Postgresql)

Installalation of PostgreSQL on Windows

Download PostgreSQL

To download PostgreSQL to install it on Windows 7, please visit the following web page :
http://www.postgresql.org/download/windows and click on the "Download" link under "One
click installer". The downloaded package will install PostgreSQL Server and pgadmin III GUI to
manage PostgreSQL Server and StackBuilder which can be used to download drivers and tools
for PostgreSQL Server.

Once you click on the said "Download" link, it will take you to another page from where you
need to select the package depending upon your OS platform. So, for installing PostgreSQL
on 32 bit Windows 7, select "Win x86-32". If you are using a 64 bit OS, select "Win x86-64".
That will start the download process and depending up on your connection speed, take a while
to get downloaded.

Make sure you have turned Third Party AntiVirus off while installing.

Once the download is finished, run the postgresql-9.1.1-1-windows.exe file and select the
location where you want to install it. By default, it is installed within Program Files folder. Then
it asks you to enter a password. Keep the port as default. When asked for "Locale", we have
selected "English, United States". It will take a while to install PostgreSQL on your system.

On completion of the installation process, you will get the following screen.
After the installation process is completed, you can access pgAdmin III, psql,
StackBuilder and PostgreSQL shell from your Program Menu under PostgreSQL 9.1.

Connect to PostgreSQL from the command line

Running the PostgreSQL interactive terminal program, called psql, which allows you to
interactively enter, edit, and execute SQL commands. At the time of installing postgres to
your operating system, it creates an "initial DB" and starts the postgres server domain
running.
Typically initdb creates a table named "postgres" owned by user "current logged in user

name" At the command line in your operating system, type the followingcommand.

Debian based systems like Ubuntu :


Connect/login as root -

user@user-pc:~$ sudo -i -u
postgres postgres@user-pc:~$
psql
psql (9.3.5, server
9.3.6) Type "help" for
help.

Redhat based systems like Centos / Fedora :


Connect/login as root -

user@user-pc:~$ su -
postgres user@user-pc:~$
psql
psql (9.3.6)
Type "help" for help.

Windows :
In windows, current user doesn't matter

C:\Program Files\PostgreSQL\9.4\bin>psql -U
postgres Password for user postgres:
psql (9.4.1)
Type "help" for help.

postgres=#
After accessing a PostgreSQL database, you can run SQL queries and more. Here are some common psql
commands

 To view help for psql commands, type \?.


 To view help for SQL commands, type \h.
 To view information about the current database connection, type \conninfo.
 To list the database's tables and their respective owners, type \dt.
 To list all of the tables, views, and sequences in the database, type \z.
 To exit the psql program, type \q.

PostgreSQL-Data Types

A datatype specifies, what kind of data you want to store in the table field. While creating
table, for each column, you have to use a datatype. There are different categories of data
types in PostgreSQL discussed below for your ready reference:

Type Data Type Description

Numeric smallint 2-byte small-range integer


Types integer, int A signed, fixed precision 4-byte
bigint stores whole numbers, large range 8 byte
real 4-byte, single precision, floating-point number
serial 4-byte auto incrementing integer
double precision 8-byte, double precision, floating-point number
numeric(m,d) Where m is the total digits and d is the
number of digits after the decimal.
Character character(n), char(n) Fixed n-length character strings.
Types character A variable length character string with limit.
varying(n),
varchar(n)
text A variable length character string of
unlimited length.
Monetary Types money currency amount,8 bytes
Boolean type boolean It specifies the state of true or false,1 byte.

Date/Time Type date date (no time of day),4 byte.


time time of day (no date),8 byte
time with time zone times of day only, with time zone,12 bytes
bit(n) Fixed-length bit string Where n is the length of
the bit
string.
varbit(n) Variable-length bit string, where n is the
bit varying(n) length of the bit string.
Assignment no.5
Data Definition Query (Create)
Objective: To create simple tables, with only the primary key constraint ( as a
table level constraint & as a field level constraint) (include all data types)
A table is a database object that holds data. A table must have unique name, via which
it can be referred. A table is made up of columns. Each column in the table must be given
a unique name within that table. Each column will also have size a data-type and an optional
constraint.
Syntax for table creation :
Create tablename( attribute list);
Attribute list : ( [ attribute name data type optional constraint] ,..........)

Create the following tables with primary key constraint

1. Create table emp (eno integer primary key, enamevarchar[50] , salary float);
2. Create table books( id integer UNIQUE, title text NOT NULL,
author_idinteger,sub_idinteger,CONSTRAINTbooks_id_pkey PRIMARY
KEY(id));
3. Create table sales_order(order_no char[10] PRIMARY KEY,
order_date date, salesman_no integer);
4. Create table client_master (client_no integer CONSTRAINT p_client PRIMARY
KEY, name varchar[50], addr text, bal_due integer);
5. Create table inventory(inv_no integer PRIMARY KEY, in_stock Boolean);
6. create table sales_order1(order_no char[10],
product_no char[10],qty_orderedinteger,product_rate
numeric(8,2),PRIMARY KEY(order_no,product_no));

SET A
1. Create a table with following details

Table Name PLAYER


Columns Column Name Column Data Type Constraints
1 player_id Integer Primary key
2 Name varchar (50)
3 Birth_date date
4 Birth_place varchar(100)
Table level constraint

2. Create a table with following details

Table Name Student


Columns Column Name Column Data Type Constraints
1 Roll_no integer
2 Class varchar (20)
3 Weight numeric (6,2)
4 Height numeric (6,2)
Table level constraint Roll_no and class as primary key
3. Create a table with details as given below

Table Name Project


Columns Column Name Column Data Type Constraints
1 project_id integer Primary key
2 Project_name varchar (20)
3 Project_ text
description
4 Status boolean
Table level
constraint

4. Create a table with details as given below

Table Name Donor


Columns Column Name Column Data Type Constraints
1 Donor_no integer Primary key
2 Donor_name varchar (50)
3 Blood_group Char(6)
4 Last_date date
Table level
constraint

Set B
Create table for the information given below by choosing appropriate data types and also
specifying proper primary key constraint on fields which are underlined
1. Property ( property_id, property_desc , area, rate, agri_status )
2. Actor ( actor_id, Actor_name, birth_date )
3. Movie (movie-no, name, release-year )
4. Hospital (hno,hname,hcity)

Set C
Create table for the information given below by choosing appropriate data types
and also specifying proper primary key constraint on fields which are underlined
1. Table ( , , , , Primary key :
)
Instructor should fill in the blanks with appropriate values

Assignment Evaluation
0: Not Done [ ]
1: Incomplete [ 2: Late Complete [ ]
3: Needs
] 4: Complete [ 5: WellDone [ ]
Improvement [ ]
]

Signature of Teacher
Assignment No.6
Objective: To create one or more tables with Check constraint , Unique constraint,
Not null constraint , in addition to the first two constraints (PK &
FK)
Constraints can be defined as either of the
following: CREATE TABLE table_name (
column_name1TYPE
column_constraint, column_name2
type column constraint,
table_constrainttable_constraint
);

The following are the commonly used column constraints in PostgreSQL:

 NOT NULL – the value of the column cannot be NULL.


 UNIQUE – the value of the column must be unique across the whole table. However,
the column can have many NULL values because PostgreSQL treats each NULL value to
be unique. Notice that SQL standard only allows one NULL value in the column that
has the UNIQUE constraint.
 PRIMARY KEY – this constraint is the combination of NOT NULL and UNIQUE
constraints. You can define one column as PRIMARY KEY by using column-level
constraint. In case the primary key contains multiple columns, you must use the
table- level constraint.
 CHECK – enables to check a condition when you insert or update data. For
example, the values in the price column of the product table must be positive
values.
 REFERENCES – constrains the value of the column that exists in a column in
another table. You use REFERENCES to define the foreign key constraint.

The following are the commonly used table constraints in PostgreSQL:

The table constraints are similar to column constraints except that they are applied to the
entire table rather than to an individual column.

The following are the table constraints:

 UNIQUE (column_list)– to force the value stored in the columns listed


insidethe parentheses to be unique.
 PRIMARY KEY(column_list) – to define the primary key that consists of
multiple columns.
 CHECK (condition) – to check a condition when inserting or updating data.
 REFERENCES– to constrain the value stored in the column that must exist in a
column in another table.

Syntax for constraints

1. Null constraint
Use of null constraint: Specifies that the column can contain null values
Use of not null constraint: Specifies that the column can not contain null values
Ex.: Create table client_master (client_no integer not null, name char(10) not
null, addr varchar(30) null, bal_due numeric);
2. Unique contarint
Use: forces the column to have unique value.
Ex.: Create table client_master (client_no integer not null, name char(10) not
null, addr varchar(30) null, bal_due numeric, ph_no integer unique);

3. Check constraint
Use : Specifies a condition that each row in the table must satisfy.Condition is
specified as a logical expression that evaluates either true orfalse.
Ex. Create table client_master (client_no varchar CHECK(client_no like ’C%’), name
char(10) check (name=upper(name)), addr varchar(30) null, bal_due numeric, ph_no
integer unique);

Set A

1. Create a table with details as given below

Table Name Machine


Columns Column Name Column Data Type Constraints
1 Machine_id integer Primary key
2 Machine_name varchar (50) NOT NULL, uppercase
Machine_typ e
3 varchar(10) Type in ( ‘drilling’, ‘milling’, ‘lathe’,
‘turning’, ‘grinding’)
4 Machine_price float Greater than zero
Machine_co
5 st float
Table level Machine_cost less than Machine_price
constraint

2. Create a table with details as given below


Table
Name Employee
Column Name
Columns Column Data Type Constraints
1 Employee_id integer Primary key
2 Employee_nam varchar (50) NOT NULL, uppercase
e
3 Employee_desg varchar(10) Designation in (
‘Manager’, ‘staff’,
‘worker’)
Employee_s Greater
4 al float than Zero
Employee_
5 ui d text Unique
Employee_uid not equal to Employee_id
Table level constraint
Set B

1. Create a table with details as given below

Table
Name Student
Colum
Columns n Column Data Type Constraints
Name
1 Stud_id integer Primary key
2 Stud _name varchar (50) NOT NULL, uppercase
3 Stud _Class varchar(10) Class in (
‘FY’, ‘SY’,
‘TY’)
Greater
4 Stud _Marks float than Zero
5 Stud _uid text Unique
Stud_uid not equal to Stud_id
Table level constraint

Assignment Evaluation
0: Not Done [ ] 1: Incomplete [ ] 2: Late Complete [ ]
3: Needs Improvement [ ] 4: Complete [ ] 5: WellDone
[]

Signature of Teacher
Assignment No.7

1. Data Definition Queries (Alter) 2. Data Definition Queries (Drop)

Objective: To drop a table from the database, to alter the schema of a table in the
Database.
1. Alter Statement: Alter table command is use to modify the structure of the table.
Syntax:
ALTER TABLE table_name action;

PostgreSQL provides many actions that allow you to:

 Add a column, drop a column, rename a column, or change a column’s data type.
 Set a default value for the column.
 Add a CHECK constraint to a column.
 Rename a table.

The following illustrates the ALTER TABLE statement variants.

1. To add a new column to a table, you use ALTER TABLE ADD COLUMN statement:

ALTER TABLE table_name ADD COLUMN new_column_name TYPE;

2. To remove an existing column, you use ALTER TABLE DROP COLUMN statement:

ALTER TABLE table_name DROP COLUMN column_name;

3. To rename an existing column, you use the ALTER TABLE RENAME COLUMN
TO statement:

ALTER TABLE table_name RENAME COLUMN


column_name TO new_column_name;

4. To change a default value of the column, you use ALTER TABLE ALTER COLUMN
SET DEFAULT or DROP DEFAULT:

ALTER TABLE table_name ALTER COLUMN [SET DEFAULT value |


DROP DEFAULT]

5. To change the NOT NULL constraint, you use ALTER TABLE


ALTER COLUMN statement:

ALTER TABLE table_name ALTER COLUMN [SET NOT NULL| DROP NOT NULL]

6. To add a CHECK constraint, you use ALTER TABLE ADD CHECKstatement:

ALTER TABLE table_name ADD CHECK expression;

7. To add a constraint, you use ALTER TABLE ADD CONSTRAINTstatement:

ALTER TABLE table_name ADD CONSTRAINT


constraint_name constraint_definition
8. To rename a table you use ALTER TABLE RENAME TOstatement:

ALTER TABLE table_name RENAME TO new_table_name;

2. Drop Statement:
Use : Deletes an object (table/view/constraint) schema from the database.
Syntax: drop table table_name;
Example: drop table employee;

Set A
Create the table given below. Assume appropriate data types for attributes. Modify the
table, as per the alter statements given below. Type \d <table name> and write the
output.
Supplier_master(supplier_no, supplier_name,city,phone-no,amount)
1. Alter table supplier_master add primary key (supplier_no);
2. Alter table supplier_master add constraint city-check check city in(‘pune’, ‘mumbai’, ‘calcutta’);
3. alter table supplier_master drop phone-no;
4. alter table supplier_master modify (supplier_namevarchar(50));
5. alter table supplier_master drop constraint city-check;
6. drop table supplier_master;

Set B
1. Remove employee table from your database. Create table employee(eno,
ename, sal). Add designation column in the employee table with values
restricted to a set of values.
2. Remove student table from your database.
Create table student( student_no, sname,date_of_birth).
Add new column into student relation named address as a text data type with NOT
NULL integrity constraint and a column phone of data type integer.
3. Consider the project relation created in the assignment 12. Add a constraint that the
project name should always start with the letter ‘R’
4. Consider the relation hospital created in assignment 12. Add a column hbudget of type int
, with the constraint that budget of any hospital should always > 50000.

Assignment Evaluation
0: Not Done [ ] 1: Incomplete [ ] 2: Late Complete [
]
3: Needs Improvement [ ] 4: Complete [ ] 5: Well Done [ ]

Signature of Teacher
Assignment No.8
Data Manipulation Queries (Insert, Delete, Update)
Objective: To insert / update / delete records using tables created in previous
Assignments. (Use simple forms of insert / update / delete statements)
INSERT syntax
INSERT INTO table_name (column1, column2 …) VALUES (value1, value2 …);

First, you specify the name of the table that you want to insert a new row after the
INSERT INTO clause, followed by a comma-separated column list.

Second, you list a comma-separated value list after the VALUES clause. The value list must
be in the same order as the columns list specified after the table name.

To add multiple rows into a table at a time, use the following syntax:

INSERT INTO table (column1, column2, …) VALUES (value1, value2, …),(value1, value2, …)
,...; You just need to add additional comma-separated value lists after the first list, each
value in the list is separated by a comma (,).

To insert data that comes from another table, use the INSERT INTO SELECT statement as follows:

INSERT INTO table(value1,value2,...) SELECT column1,column2,... FROM another_table


WHERE condition;

The WHERE clause is used to filter rows that allow you to insert partial data from
the another_table into the table.

Set A

Consider the tables created in previous assignments .Type and execute the below
statements for these tables. Write the output of each statement & justify your answer
1. INSERT INTO sales_order(s_order_no,s_order_date,client_no) VALUES (‘A2100’, now()
,’C40014’);
2. INSERT INTO client_master values(‘A2100’,’NAVEEN’,’Natraj
apt’,’pune_nagar road’,’pune’,40014);
3. Insert into client_master values (‘A2100’,’NAVEEN’,NULL,’pune_nagar road’,’pune’,40014);
4. UPDATE emp SET netsal= net_sal_basic_sal*0.15;
5. UPDATE student
SET name=’SONALI’,address=’Jayraj apartment’ WHERE stud_id=104 ;
6. DELETE from emp;
7. DELETE from emp WHERE net_sal<1000;

Set B

1. Create the following tables (primary keys are underlined.). Property(pno


,description,area) Owner(oname, address,phone)

An owner can have one or more properties, but a property belongs to exactly one owner .
Create the relations accordingly ,so that the relationship is handled properly and the
relations are in normalized form (3NF).
a) Insert two records into owner table.
b) insert 2 property records for each owner .
c) Update phone no of “Mr. Nene” to 9890278008
d) Delete all properties from “pune” owned by “ Mr. Joshi”

2. Create the following tables (primary keys are underlined.).


Emp(eno,ename,designation,sal)

Dept(dno,dname,dloc)
There exists a one-to-many relationship between emp & dept.Create the Relations accordingly,
so that the relationship is handled properly and the relations are in normalized form (3NF).
a) Insert 5 records into department table
b) Insert 2 employee records for each department.
c) increase salary of “managers” by 15%;
d) delete all employees of deparment 30;
e) delete all employees who are working as a “clerk”
f) change location of department 20 to ‘KOLKATA’.

3. Create the following tables (primary keys are


underlined.) Sales_order(s_order_no,s_order_date)
Client(client_no, name, address)
A client can give one or more sales_orders , but a sales_order belongs to exactly one client.
Create the Relations accordingly, so that the relationship is handled properly and the
relations are in normalized form (3NF).
a) insert 2 client records into client table
b) insert 3 sales records for each clientchange order date of client_no ’C004’ to 12/4/08
c) delete all sale records having order date before 10th feb. 08
d) delete the record of client “joshi”

Set C
Create the following tables(Primary keys are underlined)
Machine (mno, name, mtype,
mcost) Part (pno, pname, pdesc)
Constraints : Primary Key constraints, machine name not null,
foreign key Machine & Parts are related with one-to-many
relationship.
Create the relations accordingly,so that the relationship is handled properly and the
relations are in normalized form(3NF) and insert 5 records into eachtable.

Solve the following queries:


a) Increase the cost of machine by 10%
b) List all parts whose machine cost is greater than 10001.

Assignment Evaluatio
0: Not Done [ ] 1: Incomplete [ ] 2:Late Complete[]
3: Needs Improvement 4: Complete [ ] 5: Well Done [ ]
[ ]

Signature of Instructor
Assignment No.9

1.Simple queries 2.Aggregate queries


Objective: To understand & get a Hands-on practice on Select
statement What is an aggregate function?

An aggregate function produced a single result for an entire group or table.

Aggregate functions are used to produce summarized results. They operate on sets of
rows. They return results based on groups of rows. By default, all rows in a table are
treated as one group. The GROUP BY clause of the select statement is used to divide rows
into smaller groups.

List of aggregate functions

Name Description
COUNT This function returns the number or rows or non NULL values for a
column SUM This function returns the sum of a selected column.
MAX This function returns the largest value of a specific
column. MIN This function returns the smallest value of a
specific column. AVG This function returns the average
value for a specific column.

Syntax

aggregate_name (expression [,...] [

order_by_clause] ) OR

aggregate_name (ALL expression [,...] [

order_by_clause] ) OR

aggregate_name (DISTINCT expression [,...] [ order_by_clause] ) OR

aggregate_name (* )

Set A
Create a table employee with attributes empno, name, address, salary and deptno. Insert
atleast 10 records into the same. Execute each query
Execute following select queries .
1. Select * from emp;
2. Select empno, name from emp;
3. Select distinct deptno from emp;
4. Select * from emp where deptno = ;
5. Select * from emp where address = ‘pune’ and sal> ;
6. Select * from emp where address = ‘pune and salary between and _;
7. Select * from emp where name like ‘---%’
8. Select * from emp where name like ‘%and%’
9. Select * from emp where salary is null;
10. Select * from emp order by eno;
11. Select * from emp order by deptno, enodesc;
12. Select deptno as department, sum(salary) as total from emp group by deptno order by deptno;
13. Select deptno as department , count(eno) as total_emp from emp group by
deptno having count(eno ) > order by deptno;
14. select avg(salary) from emp;
15. select max(salary),deptno from emp group by deptno having max(sal) > _;
16. select deptno, min(salary) from emp order bydeptno;
17. update emp set salary = salary + 0.5*salary where deptno = (select deptno from
department where dname = ‘finance’);
18. update emp set deptno = (select deptno from department where dname =
‘finance’) Where deptno = (select deptno from department where dname =
‘inventory’);
19. insert into emp_backup(eno,ename) values(select eno,ename from emp);
20. delete from emp where deptno = (select deptno from department where dname=’production’);

Set B
Prerequisite : Students should know the normalization
concept Consider the relations
Person (pnumber, pname, birthdate,
income), Area (aname,area_type).
An area can have one or more person living in it , but a person belongs to exactly one
area. The attribute ‘area_type’ can have values as either urban or rural.
Create the Relations accordingly, so that the relationship is handled properly and
the relations are in normalized form (3NF).
Assume appropriate data types for all the attributes. Add any new attributes as required,
depending on the queries. Insert sufficient number of records in the relations / tables with
appropriate values as suggested by some of the queries.
Write select queries for following and execute them.

1. List the names of all people living in ‘ ’area.


2. List details of all people whose names start with the alphabet ‘_’ &
contains maximum _ alphabets in it.
3. List the names of all people whose birthday falls in the month of .
4. Give the count of people who are born on ‘ ’
5. Give the count of people whose income is below .
6. List names of all people whose income is between and ;
7. List the names of people with average income
8. List the sum of incomes of people livingin ‘ ’
9. List the names of the areas having people with maximum income (duplicate areas
must be omitted in the result)
10. Give the count of people in each area
11. List the details of people living in ‘ ’ and having income greater than ;
12. List the details Of people, sorted by person number
13. List the details of people, sorted by area, person name
14. List the minimum income of people.
15. Transfer all people living in ‘pune’ to ‘mumbai’.
16. delete information of all people staying in ‘urban’ area

65
Set C
Create the following tables(Primary keys are underlined):
Sailors(sid,sname,rate,age)
Boats(bid,bname,colour)
Reserves(sid,bid,date)
Sailors and boats are related many to many.
Create the relations accordingly,so that the relationship is handled properly and the
relations are in normalized form(3NF) and insert 5 records into eachtable.
Draw ER diagram for given relational schema and show normalization.
Solve the following quesries:
a) Find all the sailors with a rating above 8.
b) Find the ages of sailors whose name begins and ends with ‘P’.
c) Find name of sailors who have reserved red and greenboats.

Assignment Evaluation
0: Not Done [ ] 1: Incomplete 2:Late Complete[]
3: Needs [ ] 4: 5: Well Done [ ]
Improvement [
Complete [ ]

Signature of Instructor

66
Assignment No.10 Queries
with set operations
Objective: To understand & get a Hands-on practice using set operations (union
,intersect and except) with select statement.
1. Union
Use: Returns the union of two sets of values, eliminating duplicates.
Syntax: <select query> Union<select query>
Ex.: Select cname from depositor Union Select cname from borrower;
2. Union all
Use: returns union of two sets of values ,retaining all duplicates
Syntax: <select query> Union all<select query>
Ex.: Select cname from depositor Union allSelect cname from borrower;

3. Intersect
Use:returns the intersection of two sets of values ,eliminating duplicates
Syntax: <select query> intersect<select query>
Ex.: Select cname from depositor intersect Select cname from borrower;

4. Intersect all
Use: returns intersection of two sets of values ,retaining all duplicates
Syntax: <select query> intersect all<select query>
Ex.: Select cname from depositor intersect all Select cname from borrower;

5. Except
Use: returns the difference between two sets of values.i.e returns all
values of set1 not contained in set2,eliminates duplicates
Syntax: <select query> except<select query>
Ex.: Select cname from depositor Except Select cname from borrower;

6. Except all
Use: returns the difference between two sets of values.i.e returns all values of
set1 not contained in set2, retains all duplicates
Syntax: <select query> except all<select query>
Ex.: Select cname from depositor Except Select cname from borrower;

Note: To use the INTERSECT operator, the columns that appear in the SELECT statements
must follow the rules below:

1. The number of columns and their order in the SELECT clauses must the be the same.
2. The data types of the columns must be compatible.

Set A

Consider the following relations, non-teaching, teaching, department.

One deparment can have one or more teaching & non-teaching staff, but a teaching
or non- teaching staff belongs to exactly one department. Hence dno is a foreign key
in the both the relations. Create these relations in your database .

Non-teaching ( empnoint primary key, name varchar(20), address varchar(20),


salary int,dno references department)
Teaching(empnoint primary key, name varchar(20), address varchar(20), salary int,dno
references department)

67
Department (dnoint primary key,dname)
· insert at least 10 records into both the relations.
· type the following select queries & write the output and the
business task performed by each query
1. Select empno from non-teaching union select empno from teaching;
2. Select empno from non-teaching union all select empno from teaching;
3. Select name from non-teaching intersect select name from teaching;
4. Select name from non-teaching intersect all select name from teaching;
5. Select name from non-teaching except select name from teaching;

6. Select name from non-teaching except all select name from teaching

Set B
Create the following relations, for an investment firm emp(emp-
id ,emp-name, address, bdate) Investor( inv-
name , inv-no, inv-date, inv-amt)
An employee may invest in one or more investments, hence he can be an
investor.But an investor need not be an employee of the firm.
Create the Relations accordingly, so that the relationship is handled properly and the
relations are in normalized form (3NF).
Assume appropriate data types for the attributes. Add any new attributes , as required by
the queries. Insert sufficient number of records in the relations / tables with appropriate
values as suggested by some of the queries.
Write the following queries & execute them.
1. List the distinct names of customers who are either employees, or investors or both.
2. List the names of customers who are either employees , or investors or both.
3. List the names of employees who are also investors.
4. List the names of employees who are not investors

Set C
Employee (emp_no, emp_name, address, city, birth_date,
designation,salary) Project (project_no, project_name, status)
Department (Dept_no, dept_name, location)
Constraints: Employee designation is either ‘manager’, ‘staff’ , ‘worker’.
There exists a one-to-many relationship between Department and Employee. Many
employees can work on many projects controlled by a department. Create the relations
accordingly, so that the relationship is handled properly and the relations are in
normalized form (3NF) and insert 5 records into each table.
Solve the following queries:
a) Find the details of employee who is having highest salary.
b) Delete all employees of department 20.
c) List the names and salary of employees sorted by their salary.

Assignment Evaluation
0: Not Done [ ] 1: Incomplete 2:Late
3: Needs [ ] 4: complete[] 5:
Improvement[
Complete [ ] Well Done [ ]

Signature of Instructor

68
Assignment No.11
Queries &sub-queries, with joining of tables
To understand & practice session on nested queries & sub-queries using join operations.
Sub query:
A sub-query is a select-from-where expression that is nested within another query.
the ‘in’ & ‘not in’ connectivity tests for set
Set membership membership & absence
of set membership respectively.

the < some, > some, <= some, >= some, = some, <>
Set comparison some are the constructs allowed for comparison. = some
is same as the ‘in’ connectivity. <> some is not the same
as the ‘not n’i connectivity. Similarly sql also provides <
all, >all, <=all, >= all, <> all comparisons. <>all is same
as the ‘not in’ construct.

Set cardinality The ‘exists’ construct returns the value true if the
argument subquery is nonempty. We can test for
the non-existence of tuples
in a subquery by using the ‘not exists’ construct. The ‘not
exists ‘ construct can also be used to simulate the set
containment operation (the super set ). We can write
“relation A contains relation
B” as “not exists (B except A)”.

Set A
Create the following relation in your database (primary keys underlined)
Employee(ename, street, city)
Works(ename, company-name,
salary) Company(company-name,
city) Manages(ename, manager-
name )
An employee can work in one or more companies, a company can have one or more
employees working in it. Hence the relation ‘works’ with keyattributes as ename, company-
name.
An employee manages one or more employees, but an employee is managed by
exactly one employee ( a recursive relationship), hence the relation ‘manages’
with key ename.
Insert sufficient number of records in the relations / tables with appropriate values
as suggested by some of the queries.
Type the following queries , execute them and give the business task performed by each query
1. select ename from works w where salary >= all (select max(salary) from works));
2. select ename form works w where salary = (select max(salary) from
works w1 where w1.company-name = w.company-name));
3. select manager-name from manages where manager-name in(select ename from
works where company-name = “”);
4. select manager-name from manages where manager-name not in(select ename from
works where company-name = “ ”);
5. select ename from works w where salary > some (select salary from works where
company- name not in (select company-name from company where city = “ _”));
6. select ename from employee e where city = ( select city from employee e1 ,
manages m where m.ename = e.ename and m.manager-name = e1.ename);
7. select * from employee where ename in (select manager-name from manages)
8 select city count(*) from employee group by city having count(*) >= all (select count(*) from

69
employee group by city)
9. select ename from works w where salary <> all (select salary from
works where ename<>w.ename);
10. select company-name, sum(salary) from works w groupby company-name having sum(sal)
>= all ( select sum(sal) from works group by company-name)
11. select ename from employee e where city in(‘ ’,’ ’);
12. select ename from employee e where city = (select city from company c,
works w where w.ename = e.name and c.company-name = w.company-name);

Set B
Create the following relations :
Emp(eno,name,dno,salary)
Project(pno,pname,control-
dno,budget)

Each employee can work on one or more projects, and a project can have many
employees working in it. The number of hours worked on each project , by an
employee also needs to be stored.
Create the Relations accordingly, so that the relationship is handled properly and
the relations are in normalized form (3NF).
Assume appropriate data types for the attributes. Add any new attributes ,
new relations as required by the queries.
Insert sufficient number of records in the relations / tables with appropriate values
as suggested by some of the queries.
Write the queries for following business tasks & execute them.

1. list the names of departments that controls projects whose budget is greater than .
2.list the names of projects, controlled by department No , whose budget is greater
than atleast one project controlled by department No .
3. list the details of the projects with second maximum budget

4. list the details of the projects with third maximum budget.


5. list the names of employees, working on some projects that employee number is working.
6. list the names of employees who do not work on any project that employee number
works on
7. list the names of employees who do not work on any project controlled by ‘
_’ department
8. list the names of projects along with the controlling department name, for those
projects which has atleast employees working on it.
9. list the names of employees who is worked for more than 10 hrs on
atleast one project controlled by ‘ ’ dept.
10. list the names of employees , who are males , and earning the maximum
salary in their department.
11. list the names of employees who work in the same department as ‘ ’.
12. list the names of employees who do not live in or .

70
Set C
Execute following queries on the relations mentioned in above case study
1. list the names of projects along with the controlling department name, for those
projects which has atleast employees working on it.
2. list the names of employees who is worked for more than 10 hrs on
atleast one project controlled by ‘ ’ dept.
3. list the names of employees , who are males , and earning the maximum
salary in their department.
4. list the names of employees who work in the same department as ‘ ’.
5. list the names of employees who do not live in or .

Assignment Evaluation
0: Not Done [ ] 1: Incomplete [ ] 2:Late Complete[]
3: Needs Improvement [ 4: Complete [ ] 5: Well Done [ ]
]

Signature of Instructor

71
Assignment No.12
Queries &sub queries, with joining of table
Execute the following queries on the table created in previous assignments.
Set A
Project-Employee database
Consider the database maintained by a company which stores the details of the projects
assigned to the employees.
Following are the tables:

PROJECT (PNO INTEGER, P_NAME CHAR(30), PTYPE CHAR(20),DURATION


INTEGER) EMPLOYEE (ENO INTEGER, E_NAME CHAR (20), QUALIFICATION CHAR
(15), JOINDATE DATE)
The relationship is as follows:
PROJECT - EMPLOYEE: M-M Relationship , with descriptive attributes as start_date
(date), no_of_hours_worked (integer).

Solve the Queries


1. Find the names of the employees starting with ’A’.
2. Find the details of employees working on the project “System”.
3. Find the employee numbers of the employees, who do not work on project “Robotics”.
4. Get employee number of the employee, who works on at least one project that
employee number ‘2000’ works on.
5. List the names of the first three employees in alphabetical order.
6. Find the names of the employees whose duration is more than three years.
Set B
Bank database
Consider the following database maintained by a Bank. The Bank maintains
information about its branches, customers and their loan applications.

Following are the tables:


BRANCH (bid integer, brname char (30), brcity char (10)) CUSTOMER
(cno integer, cname char (20), caddr char (35), city (20))
LOAN_APPLICATION (lno integer, lamtrequired money, lamtapproved money, l_date date)

The relationship is as follows:


BRANCH, CUSTOMER, LOAN_APPLICATION are related with ternary
relationship. TERNARY (bid integer, cno integer, lno integer).

Solve the Queries


1. Find the names of the customers for the “Aundh” branch.
2. List the names of the customers who have received loan less than their requirement.
3. Find the maximum loan amount approved.
4. Find out the total loan amount sanctioned by “Deccan “branch.
5. Count the number of loan applications received by “M.G.ROAD” branch.
6. List the names of the customer along with the branch names who have applied
for loan in the month of September.

72
Set C
Student- Teacher database
Consider the following database maintained by a school. The school maintains
information about students and the teachers. It also gives information of the subject
taught by the teacher.

Following are the tables:


STUDENT (sno integer, s_name char(30), s_class char(10), s_addr char(50))
TEACHER (tno integer, t_name char (20), qualification char(15),experience integer)

The relationship is as follows:


STUDENT-TEACHER: M-M with descriptive attribute SUBJECT.

Solve the queries


1. Find the minimum experienced teacher.
2. Find the number of teachers having qualification “Ph. D.”.
3. List the names of the students to whom “Mr. Patil” is teaching along with the
subjects he is teaching to them.
4. Find the subjects taught by each teacher.
5. List the names of the teachers who are teaching to a student named“Suresh”.
6. List the names of all teachers along with the total number of students they are teaching.

Assignment Evaluation
0: Not Done [ ] 1: Incomplete [ ] 2:Late Complete[]
3: Needs Improvement [ 4: Complete [ ] 5: Well Done [ ]
]

Signature of Instructor

73
Assignment No.13 Case
studies
Set A
Business trip database
Consider the business trip database that keeps track of the business trips of salesman in an office.

Following are the tables:


SALESMAN (sno integer, s_name char (30), start_year year, deptno varchar (10)) TRIP (tno
integer, from_city char (20), to_city char (20), departure_date date, return date)
DEPT (deptno varchar (10), dept_name char(20)) ,expense (eid integer, amount money) The
relationship is as follows
DEPT-SALESMAN 1 TO M
SALESMAN - TRIP 1 TO M
TRIP - EXPENSE 1 TO 1
Execute the following queries
1. Increase the expenses of all the trips by Rs. 5000.
2. Give the details for trips that exceed Rs. 10,000 in expenses.
3. List the salesman numbers and names of the salesmen who made trips to Calcutta.
4. Delete all the trips made by department “computer” having
expenses morethan Rs.15000.
5. Find the departments from which the salesmen have done highest number of trips.
6. Find the total expenses incurred by the salesman “Mr. Patil”.
Set B
Warehouse Database

CITIES (city char (20), state char(20))


WAREHOUSES (wid integer, wname char (30), location char(20))
STORES (sid integer,store_name char(20), location_city char(20))
ITEMS (itemno integer, description text, weight decimal(5,2), cost decimal(5,2) )
CUSTOMER(cno integer, cname char(50),addr varchar(50), c_city char(20))
ORDERS(o_no int, o_date date)

The relationship is as follows CITIES-


WAREHOUSES 1 TO M
WAREHOUSES
- STORES 1 TO M CUSTOMER
– ORDERS 1 TO M
ITEMS – ORDERS M TO M relationship with descriptive attribute ordered_quantity
STORES-ITEMS M TO M RELATION with descriptive attribute quantity

Solve the following queries.


1. Find the item that has minimum weight.
2. Find the different warehouses in “Pune”.
3. Find the details of items ordered by a customer “Mr. Patil”.
4. Find a Warehouse which has maximum stores.
5. Find an item which is ordered for minimum number of times.
6. Find the details orders given by each customer.

74
Set C
movie database
movies(m_name, release_year,
budget) actor(a_name, role,
charges, a_address)
producer(producer_id, name,
p_address)
each actor has acted in one or more movies. each producer has produced many movies and
each movie can be produced by more than one producers. each movie has one or more
actors acting in it, in different roles.
create the relations accordingly, so that the relationship is handled properly and the
relations are in normalized form(3nf).
insert sufficient number of appropriate records.
solve the queries:
1. list the names of actors who have acted in at least one movie, inwhich ‘ ’
has acted.
2. list the names of the movies with the highest budget.
3. list the names of actors who have acted in the maximum number of movies.
4. list the names of movies, produced by more than one producer.
5. list the names of actors who are given with the maximum charges for their movie.
6. list the names of producers who produce the same movie as ‘_ ’.
7. list the names of actors who do not live in or city.

Assignment Evaluation
0: Not Done [ ] 1: Incomplete [ ] 2:Late Complete[]
3: Needs Improvement [ 4: Complete [ ] 5:Well Done [ ]
]

Signature of Instructor

You might also like