100% found this document useful (1 vote)
1K views88 pages

Ii Puc Computer Science Lab Manual Page 1 of 88

The document is a lab manual that outlines various programs for students to complete. It contains 3 sections: Section A focuses on C++ and data structures programs, Section B covers SQL programs, and Section C involves HTML programs. Some example programs are writing a C++ program to find the frequency of an element in an array, generating an electricity bill table in SQL, and creating a study timetable in HTML. Students are instructed to practice all programs in their record and exams will contain questions from either the C++ or SQL/HTML sections.

Uploaded by

Aman kekkar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
1K views88 pages

Ii Puc Computer Science Lab Manual Page 1 of 88

The document is a lab manual that outlines various programs for students to complete. It contains 3 sections: Section A focuses on C++ and data structures programs, Section B covers SQL programs, and Section C involves HTML programs. Some example programs are writing a C++ program to find the frequency of an element in an array, generating an electricity bill table in SQL, and creating a study timetable in HTML. Students are instructed to practice all programs in their record and exams will contain questions from either the C++ or SQL/HTML sections.

Uploaded by

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

II PUC Computer Science Lab Manual Page 1 of 88

www.gkmvkalyan.blogspot.com

www.gkmvkalyan.blogspot.com
II PUC Computer Science Lab Manual Page 2 of 88

Programs to be executed in Lab.


Date Program Name
Write a C++ program to find the frequency presence of an
element in an array.
Write a C++ program to insert an element into an array at a
given position.
Write a C++ program to delete an element from an array from a
given position.
Write a C++ program to sort the element of an array in
ascending order using insertion sort.
Write a C++ program to search for a given element in an array
using binary search method.
Write a C++ program to compute simple interest and to display
the result.
Write a C++ program to find the roots of quadratic equations.

Write a C++ program to find the area of square/ rectangle/


triangle using function overloading.
Write a C++ program to find cube of a number using inline
function.
Write a C++ program to find sum of the series 1 + x + x2+
x3+….xn using constructors.
Create a base class containing the data member roll number and
name. Also create a member function to read and display the
data using the concept of single level inheritance. Create a
derived class that contains marks of two subjects and total
marks as the data members.
Create a class containing the following data members Register
No, Name and Fees. Also create a member function to read and
display the data using the concept of pointers to objects.
HTML-1, Write a HTML program to create a study time table

HTML-2, Create an HTML program with table and Form.

SQL-1, Generate the electricity bill for one customer

SQL-2, Create a student database and compute the results

******

www.gkmvkalyan.blogspot.com
II PUC Computer Science Lab Manual Page 3 of 88

Slno Program Name


SECTION- A (C++ & DATA STRUCTURES)
1 Write a C++ program to find the frequency presence of an element
in an array.
2 Write a C++ program to insert an element into an array at a given
position.
3 Write a C++ program to delete an element from an array from a
given position.
4 Write a C++ program to sort the element of an array in ascending
order using insertion sort.
5 Write a C++ program to search for a given element in an array
using binary search method.
6 Write a C++ program to create a class with data members principal,
time and rate. Create a member function to accept data values, to
compute simple interest and to display the result.
7 Write a C++ program to create a class with data members a, b, c
and member functions to input data, compute the discriminates
based on the following conditions and print the roots.
If discriminates = 0, print the roots are equal and their value.
If discriminates > 0, print the real roots and their values.
If discriminates < 0, print the roots are imaginary and exit the
program.
8 Write a C++ program to find the area of square/ rectangle/ triangle
using function overloading.
9 Write a C++ program to find cube of a number using inline function.
10 Write a C++ program to find sum of the series 1 + x + x2+ x3+….xn
using constructors.
11 Create a base class containing the data member roll number and
name. Also create a member function to read and display the data
using the concept of single level inheritance. Create a derived class
that contains marks of two subjects and total marks as the data
members.
12 Create a class containing the following data members Register No,
Name and Fees. Also create a member function to read and display
the data using the concept of pointers to objects.
17 Write a C++ program to perform push items into the stack.
18 Write a C++ program to perform pop items into the stack.
19 Write a C++ program to perform Enqueue and Dequeue.
20 Write a program to create a linked list and appending nodes.

www.gkmvkalyan.blogspot.com
II PUC Computer Science Lab Manual Page 4 of 88

Slno Program Name


SECTION- B (SQL)
Generate the electricity bill for one customer
Create a table for house hold Electricity bill with the following fields.
Field Name Type
RRNO VARCHAR2(10)
CUSNAME VARCHAR2(15)
BILLINGDATE DATE
UNITS NUMBER(4)
Insert 10 records into the table.
15 1. Check the structure of table and note your observation.
2. Add two fields to the table.
a. BILL_AMT NUMBER(6,2)
b. DUE_DATE DATE
3. Compute the bill amount for each customer as per the following
rules.
a. MIN_AMT Rs. 50
b. First 100 units Rs 4.50/Unit
c. >100 units Rs. 5.50/Unit
4. Compute due date as BILLING_DATE + 15 Days
5. List all the bills generated.
Create a student database and compute the results.
Create a table for class of students with the following fields.
Field Name Type
IDNO NUMBER(4)
16 SNAME VARCHAR2(15)
SUB1 NUMBER(3)
SUB2 NUMBER(3)
SUB3 NUMBER(3)
SUB4 NUMBER(3)
SUB5 NUMBER(3)
SUB6 NUMBER(3)
1. Add records into the table for 10 students for Student ID, Student
Name and marks in 6 subjects using INSERT command.
2. Display the description of the fields in the table using DESC
command.
3. Alter the table and calculate TOTAL and PERC_MARKS.
4. Compute the RESULT as “PASS” or “FAIL” by checking if the
student has scored more than 35 marks in each subject.

www.gkmvkalyan.blogspot.com
II PUC Computer Science Lab Manual Page 5 of 88

5. List the contents of the table.


6. Retrieve all the records of the table.
7. Retrieve only IDNO and SNAME of all the students.
8. List the students who have result as “PASS”.
9. List the students who have result as “FAIL”.
10. Count the number of students who have passed.
11. Count the number of students who have failed.
12. List the students who have percentage greater than 60.
13. Sort the table according to the order of IDNO.
Generate the Employee details and compute the salary based on the
department.
Create the following table EMPLOYEE
Field Name Type
EMP_ID NUMBER(4)
21 DEPT_ID NUMBER(2)
EMP_NAME VARCHAR2(15)
EMP_SALARY NUMBER(5)
Create another table DEPARTMENT
Field Name Type
DEPT_ID NUMBER(2)
DEPT_NAME VARCHAR2(20)
SUPERVISOR VARCHAR2(20)
Assume the DEPARTMENT names as Purchase (Id-01), Accounts (Id-
02), Sales (Id-03), and Apprentice (Id-04)
Enter 10 rows of data for table EMPLOYEE and 4 rows of data for
DEPARTMENT table.
Write the SQL statements for the following:
1. Find the names of all employees who work for the Accounts
department.
2. How many employees work for Accounts department?
3. What are the Minimum, Maximum and Average salary of
employees working for Accounts department?
4. List the employees working for particular supervisor.
5. Retrieve the department names for each department where only
one employee works.
6. Increase the salary of all employees in the sales department by
15%.
7. Add new Colum to the table EMPLOYEE called BONUS NUMBER(5)
and compute 5% of the salary to the said field.
8. Delete all the rows for the employee in the Apprentice
department.
Create database for the bank transaction.
22 11. Create a table for customer

www.gkmvkalyan.blogspot.com
II PUC Computer Science Lab Manual Page 6 of 88

2. Create a table bank.


3. Insert data values into customers table
4. Insert data values for bank table
5. to display all records from customer table
6. to display all records from bank table.
7.To display all records from bank whose transaction date is 12-Feb-
2019.
8.To join two tables
9.Display records from customers whose name starts with 'S'
10.Display today’s date.
SECTION- C (HTML)
13 Write a HTML program to create a study time table
14 Create an HTML program with table and Form.

Note:
✓ Students should practice and write all programs in the record.
✓ In Final Lab Examination there will be 2 parts.
❖ PART-A → Only C++ Programs will be asked.
❖ PART-B → Either SQL or HTML Programs will be asked.

www.gkmvkalyan.blogspot.com
II PUC Computer Science Lab Manual Page 7 of 88

1. Write a program to find the frequency of presence of an element in an


array.

#include<iostream.h>
#include<conio.h>

class GKFrequency
{
private:
int a[50], n, i, ele, freq;
public:
void input( );
void findfreq( );
void output( );
};

void GKFrequency ::input( )


{
cout<<"Enter the size of the array "<<endl;
cin>>n;
cout<<"Enter the array elements "<<endl;
for( i=0; i<n; i++)
cin>>a[i];
cout<<"Enter the element to find the frequency"<<endl;
cin>>ele;
}

void GKFrequency::findfreq( )
{
freq=0;
for( i=0; i<n; i++)
if(ele == a[i]) freq++;
}

www.gkmvkalyan.blogspot.com
II PUC Computer Science Lab Manual Page 8 of 88

void GKFrequency::output( )
{
cout<<ele<<" Occurs "<<freq<<" Time ";
}

void main( )
{
GKFrequency f;
clrscr( );
f.input( );
f.findfreq( );
f.output( );
getch( );
}

www.gkmvkalyan.blogspot.com
II PUC Computer Science Lab Manual Page 9 of 88

OUTPUT-1

OUTPUT-2

www.gkmvkalyan.blogspot.com
II PUC Computer Science Lab Manual Page 10 of 88

Student’s Output

www.gkmvkalyan.blogspot.com
II PUC Computer Science Lab Manual Page 11 of 88

2. Write a program to insert an element into an array at a given position.

#include<iostream.h>
#include<conio.h>
#include<stdlib.h>

class GKInsertion
{
private:
int a[50], n, pos, ele, i;
public:
void input( );
void addelement( );
void output( );
};

void GKInsertion::input( )
{
cout<<"Enter the size of the array"<<endl;
cin>>n;
cout<<"Enter the elements for the array"<<endl;
for(i=0; i<n; i++)
cin>>a[i];
cout<<"Enter the position of the element in the array"<<endl;
cin>>pos;
cout<<"Enter the element to be inserted"<<endl;
cin>>ele;
}

void GKInsertion::addelement( )
{
if(pos>n)
{
cout<<"Out of array limits";
getch( );
exit(0);
}

www.gkmvkalyan.blogspot.com
II PUC Computer Science Lab Manual Page 12 of 88

for(i=n-1; i>=pos; i--)


a[i+1] = a[i];
a[pos] = ele;
n = n+1;
}

void GKInsertion::output( )
{
cout<<"Array elements after insertion are:"<<endl;
for(i=0; i<n; i++)
cout<<a[i]<<"\t";
}

void main( )
{
GKInsertion i;
clrscr( );
i.input( );
i.addelement( );
i.output( );
getch( );
}

www.gkmvkalyan.blogspot.com
II PUC Computer Science Lab Manual Page 13 of 88

OUTPUT-1

OUTPUT-2

www.gkmvkalyan.blogspot.com
II PUC Computer Science Lab Manual Page 14 of 88

Student’s Output

www.gkmvkalyan.blogspot.com
II PUC Computer Science Lab Manual Page 15 of 88

3. Write a program to delete an element from an array from a given


position.

#include<iostream.h>
#include<conio.h>
#include<stdlib.h>

class GKDeletion
{
private:
int a[50], n, pos, i;
public:
void input( );
void remove( );
void output( );
};

void GKDeletion::input( )
{
cout<<"Enter the size of the array"<<endl;
cin>>n;
cout<<"Enter the elements for the array"<<endl;
for (i=0; i<n; i++)
cin>>a[i];
cout<<"Enter the position to an delete an element"<<endl;
cin>>pos;
}

void GKDeletion::remove( )
{
if(pos>n-1)
{
cout<<"Out of array limits";
getch( );
exit(0);
}

www.gkmvkalyan.blogspot.com
II PUC Computer Science Lab Manual Page 16 of 88

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


a[i] = a[i+1];
n = n-1;
}

void GKDeletion::output( )
{
cout<<"After deletion the array elements are"<<endl;
for(i=0; i<n; i++)
cout<<a[i]<<"\t";
}

void main( )
{
GKDeletion d;
clrscr();
d.input( );
d.remove( );
d.output( );
getch( );
}

www.gkmvkalyan.blogspot.com
II PUC Computer Science Lab Manual Page 17 of 88

OUTPUT-1

OUTPUT-2

www.gkmvkalyan.blogspot.com
II PUC Computer Science Lab Manual Page 18 of 88

Student’s Output

www.gkmvkalyan.blogspot.com
II PUC Computer Science Lab Manual Page 19 of 88

4. Write a program to sort the elements of an array in ascending order


using insertion sort.

#include<iostream.h>
#include<conio.h>
#include<stdlib.h>

class GKSort
{
private:
int a[50], n, i;
public:
void input( );
void insertionsort( );
void output( );
};

void GKSort::input( )
{
cout<<"Enter the size of the array"<<endl;
cin>>n;
cout<<"Enter the elements for the array"<<endl;
for(i=0; i<n; i++)
cin>>a[i];
}

void GKSort::insertionsort( )
{
int j, temp;
for(i=1; i<n; i++)
{
j = i;
while(j >= 1)
{
if(a[j] < a[j-1])
{
temp = a[j];

www.gkmvkalyan.blogspot.com
II PUC Computer Science Lab Manual Page 20 of 88

a[j] = a[j-1];
a[j-1] = temp;
}
j = j-1;
}
}
}

void GKSort::output( )
{
cout<<"Sorted List"<<endl;
for(i=0; i<n; i++)
cout<<a[i]<<"\t";
}

void main( )
{
GKSort s;
clrscr();
s.input( );
s.insertionsort( );
s.output( );
getch( );
}

www.gkmvkalyan.blogspot.com
II PUC Computer Science Lab Manual Page 21 of 88

OUTPUT-1

Student’s Output

www.gkmvkalyan.blogspot.com
II PUC Computer Science Lab Manual Page 22 of 88

5. Write a program to search for a given element in an array using Binary


search method.

#include<iostream.h>
#include<conio.h>

class GKSearch
{
private:
int a[50], i, n, ele, loc, low, high, mid;
public:
void input( );
void bsearch( );
void output( );
};

void GKSearch::input( )
{
cout<<"Enter the size of the array:"<<endl;
cin>>n;
cout<<"Enter the array elements in sorted order:"<<endl;
for(i=0;i<n;i++)
cin>>a[i];
cout<<"Enter the element to search:"<<endl;
cin>>ele;
}

void GKSearch::bsearch( )
{
loc = -1;
low = 0;
high = n-1;
while(low <= high)
{
mid = (low+high)/2;

www.gkmvkalyan.blogspot.com
II PUC Computer Science Lab Manual Page 23 of 88

if(ele == a[mid])
{
loc = mid;
break;
}
else
if(ele < a[mid])
high = mid-1;
else
low = mid+1;
}
}

void GKSearch::output( )
{
if(loc >=0)
cout<<ele<<" Found at Location "<<loc;
else
cout<<ele<<" Element does not exist";
}

void main( )
{
GKSearch s;
clrscr( );
s.input( );
s.bsearch( );
s.output( );
getch( );
}

www.gkmvkalyan.blogspot.com
II PUC Computer Science Lab Manual Page 24 of 88

OUTPUT-1

OUTPUT-2

www.gkmvkalyan.blogspot.com
II PUC Computer Science Lab Manual Page 25 of 88

Student’s Output

www.gkmvkalyan.blogspot.com
II PUC Computer Science Lab Manual Page 26 of 88

6. Write a program to create a class with data members principle, time and
rate. Create member functions to accept data values to compute simple
interest and to display the result.

#include<iostream.h>
#include<conio.h>
class GKSI
{
private:
double p, t, r, si;
public:
void input()
{
cout<<"enter value for p,t,r "<<endl;
cin>>p>>t>>r;
}

void calculate()
{
si=(p*t*r)/100;
}

void output()
{
cout<<"simple interest= "<<si;
}
};

void main()
{
GKSI x;
clrscr();
x.input();
x.calculate();
x.output();
getch();
}

www.gkmvkalyan.blogspot.com
II PUC Computer Science Lab Manual Page 27 of 88

OUTPUT-1

Student’s Output

www.gkmvkalyan.blogspot.com
II PUC Computer Science Lab Manual Page 28 of 88

7. Write a program to create a class with data members a, b, c and member


functions to input data, compute the discriminant based on the following
conditions and print the roots.
1. If discriminant=0, print the roots are real are equal.
2. If the discriminant is>0, print the roots are real and different.
3. If the discriminant<0, print the roots are imaginary.

#include<iostream.h>
#include<conio.h>
#include<math.h>

class GKquadratic
{
private:
double a, b, c, d, r1, r2;
public:
void input()
{
cout<<"enter the co-efficient"<<endl;
cin>>a>>b>>c;
}

void output()
{
d=b*b-4*a*c;
if(d==0)
{
r1=-b/(2*a);
r2=r1;
cout<<"Roots are equal"<<endl;
cout<<"Roots are = "<<r1<<” and “ <<r2;
}

if(d>0)
{
r1=(-b+sqrt(d))/(2*a);
r2=(-b-sqrt(d))/(2*a);

www.gkmvkalyan.blogspot.com
II PUC Computer Science Lab Manual Page 29 of 88

cout<<"Roots are real and distinct"<<endl;


cout<<"Roots are "<<r1<<" and " <<r2;
}

if(d<0)
{
cout<<"Roots are imaginary";
}

}
};

void main()
{
GKquadratic Q;
clrscr();
Q.input();
Q.output();
getch();
}

www.gkmvkalyan.blogspot.com
II PUC Computer Science Lab Manual Page 30 of 88

OUTPUT-1

OUTPUT-2

OUTPUT-3

www.gkmvkalyan.blogspot.com
II PUC Computer Science Lab Manual Page 31 of 88

Student’s Output

www.gkmvkalyan.blogspot.com
II PUC Computer Science Lab Manual Page 32 of 88

8. Program to find the area of a square/rectangle/triangle using function


overloading.

#include<iostream.h>
#include<conio.h>
#include<math.h>

class GKfunoverload
{
private:
float s;
public:

double area(double a)
{
return(a*a);
}

double area(double l, double b)


{
return(l*b);
}

double area(double a, double b, double c)


{
s=(a+b+c)/2.0;
return(sqrt(s*(s-a)*(s-b)*(s-c)));
}
};

www.gkmvkalyan.blogspot.com
II PUC Computer Science Lab Manual Page 33 of 88

void main()
{
double x,y,z;
int ans;
GKfunoverload F;
clrscr();
cout<<"Enter the number of sides(1,2,and 3)"<<endl;
cin>>ans;

if(ans==1)
{
cout<<"enter the side ";
cin>>x;
cout<<"Area of the square= "<<F.area(x);
}

else if(ans==2)
{
cout<<"enter two sides ";
cin>>x>>y;
cout<<"Area of the rectangle= "<<F.area(x,y);
}

else if(ans==3)
{
cout<<"enter three sides ";
cin>>x>>y>>z;
cout<<"Area of the triangle= "<<F.area(x,y,z);
}
else
cout<<”invalid side”;
getch();
}

www.gkmvkalyan.blogspot.com
II PUC Computer Science Lab Manual Page 34 of 88

OUTPUT

www.gkmvkalyan.blogspot.com
II PUC Computer Science Lab Manual Page 35 of 88

Student’s Output

www.gkmvkalyan.blogspot.com
II PUC Computer Science Lab Manual Page 36 of 88

9. Program to find the cube of a number using inline functions.

#include<iostream.h>
#include<conio.h>

class GKLine
{
public:
inline int cube(int a)
{
return(a*a*a);
}
};

void main()
{
GKLine L;
int n;
clrscr();
cout<<"Enter the number to find its cube ";
cin>>n;
cout<<"cube of " <<n<<” is ”<<L.cube(n);
getch();
}

OUTPUT-1

Student’s Output

www.gkmvkalyan.blogspot.com
II PUC Computer Science Lab Manual Page 37 of 88

10. Write a program to find the sum of the series 1+ x + x2 + … + xn using


constructors.
#include<iostream.h>
#include<conio.h>
#include<math.h>
class GKSeries
{
private:
int n,x,i,sum;
public:
GKSeries()
{
sum=1;
}
void input();
void calculate();
void output();
};

void GKSeries :: input()


{
cout<<"enter the value of x"<<endl;
cin>>x;
cout<<"enter the value of n"<<endl;
cin>>n;
}

void GKSeries :: calculate()


{
for(i=1;i<=n; i++)
sum=sum+pow(x,i);
}

void GKSeries :: output()


{
cout<<"Sum of the series is "<<sum;
}

www.gkmvkalyan.blogspot.com
II PUC Computer Science Lab Manual Page 38 of 88

void main()
{
GKSeries S;
clrscr();
S.input();
S.calculate();
S.output();
getch();
}

OUTPUT-1

Student’s Output

www.gkmvkalyan.blogspot.com
II PUC Computer Science Lab Manual Page 39 of 88

11. Create a base class containing the data members roll number and
name. Also create a member function to read and display the data using the
concept of single level inheritance. Create a derived class that contains
marks of two subjects and total marks as data members.

#include<iostream.h>
#include<conio.h>
class GKStudent
{
private:
int regno;
char name[50];
public:
void baseinput()
{
cout<<"enter the name ";
cin>>name;
cout<<"enter the regno ";
cin>>regno;
}
void baseoutput()
{
cout<<"Regno "<<regno<<endl;
cout<<"Name "<<name<<endl;
}
};
class GKMarks : public GKStudent
{
private:
int m1, m2, total;
public:
void deriveinput()
{
cout<<"enter two subject marks"<<endl;
cin>>m1>>m2;
total=m1+m2;
}

www.gkmvkalyan.blogspot.com
II PUC Computer Science Lab Manual Page 40 of 88

void deriveoutput()
{
cout<<"Subject1 "<<m1<<endl;
cout<<"Subject2 "<<m2<<endl;
cout<<"Total Marks "<<total;
}
};

void main()
{
GKMarks M;
clrscr();
M.baseinput();
M.baseoutput();
M.derivinput();
M.derivoutput();
getch();
}

OUTPUT-1

www.gkmvkalyan.blogspot.com
II PUC Computer Science Lab Manual Page 41 of 88

Student’s Output

www.gkmvkalyan.blogspot.com
II PUC Computer Science Lab Manual Page 42 of 88

12. Create a class containing the following data members register No.,
name and fees. Also create a member function to read and display the data
using the concept of pointers to objects.
#include<iostream.h>
#include<conio.h>
class GKStudent
{
private:
int regno,fees;
char name[100];
public:
void input()
{
cout<<"enter the regno ";
cin>>regno;
cout<<"enter the name ";
cin>>name;
cout<<"enter the fees ";
cin>>fees;
}
void output()
{
cout<<"Register number "<<regno<<endl;
cout<<"Student Name "<<name<<endl;
cout<<"Fees "<<fees<<endl;
}
};
void main()
{
GKStudent Std, *ptr;
clrscr();
ptr=&Std;
ptr->input();
ptr->output();
getch();
}

www.gkmvkalyan.blogspot.com
II PUC Computer Science Lab Manual Page 43 of 88

Output

Student’s Output

www.gkmvkalyan.blogspot.com
II PUC Computer Science Lab Manual Page 44 of 88

HTML Programs

HTML-1, Write a HTML Program to Create Study Time Table.

<html>
<head>
<title>MY Time Table</title>
</head>
<body bgcolor="PINK">
<H1><center>Study Time Table</center></H1>

<table border="3" align="center">


<tr>
<th>Day/Time</th>
<th>7:00-8:00</th>
<th>8:00-8:30</th>
<th>8:30-9:30</th>
<th>9:30-10:30</th>
</tr>

<tr>
<td>MONDAY</td>
<td>Home Work</td>
<td>Dinner</td>
<td>Physics</td>
<td>Computer</td>
</tr>

<tr>
<td>TUESDAY</td>
<td>Home Work</td>
<td>Dinner</td>
<td>Chemistry</td>
<td>Maths</td>
</tr>

www.gkmvkalyan.blogspot.com
II PUC Computer Science Lab Manual Page 45 of 88

<tr>
<td>WEDNESDAY</td>
<td>Home Work</td>
<td>Dinner</td>
<td>Language</td>
<td>English</td>
</tr>

<tr>
<td>THURSDAY</td>
<td>Home Work</td>
<td>Dinner</td>
<td>Physics</td>
<td>Computer</td>
</tr>

<tr>
<td>FRIDAY</td>
<td>Home Work</td>
<td>Dinner</td>
<td>Chemistry</td>
<td>Maths</td>
</tr>

<tr>
<td>SATURDAY</td>
<td>Home Work</td>
<td>Dinner</td>
<td>Language</td>
<td>English</td>
</tr>
</table></body></html>

www.gkmvkalyan.blogspot.com
II PUC Computer Science Lab Manual Page 46 of 88

www.gkmvkalyan.blogspot.com
II PUC Computer Science Lab Manual Page 47 of 88

HTML-2, Create an HTML program with table and Form.

<html>
<head>
<title>Table and Form</title>
</head>

<body bgcolor="PINK">
<h2> Student Data Form</h2>

<table border=5px >


<form>

<tr>
<td>Student Name: </td>
<td><input type=”text” name=”sname”></td>
</tr>

<tr>
<td>Date of Birth: </td>
<td><input type="date" name="DOB" > </td>
</tr>

<tr>
<td>Gender: </td>
<td><input type="radio" name=”gender">Male
<input type="radio" name=”gender">Female
</td>
</tr>

<tr>
<td>Course: </td>
<td><select Name="dropdown">
<option value=1>Select Course</option>
<option value=2>PCMB</option>
<option value=3>PCMC</option>
<option value=4>PCME</option>

www.gkmvkalyan.blogspot.com
II PUC Computer Science Lab Manual Page 48 of 88

</select></td>
</tr>

<tr>
<td>Mobile Number: </td>
<td><input type=”text” name=”mobileno”></td>
</tr>

<tr>
<td><input type="submit" value="Submit"></td>
</tr>

</form></table></body></html>

Output

www.gkmvkalyan.blogspot.com
II PUC Computer Science Lab Manual Page 49 of 88

SQL Programs

SQL-1, Generate the Electricity Bill for one consumer

Create a table for house hold Electricity bill with the following fields.
Field Name Type
RR_NO VARCHAR2(10)
CUS_NAME VARCHAR2(15)
BILLING_DATE DATE
UNITS NUMBER(5)

drop table ebill;

create table ebill(rrno varchar2(10),


cname varchar2(15),
billdate date,
unitsused number(5));

Insert 10 records into the table.


insert into ebill values('a101','Rama','10-jun-2018',650);
insert into ebill values('a102','Ranga','15-jan-2018',50);
insert into ebill values('a103','Rani','10-jul-2018',250);
insert into ebill values('a104','Roja','12-aug-2018',650);
insert into ebill values('a105','Roopa','13-jun-2018',850);
insert into ebill values('a106','Ramya','10-feb-2018',460);
insert into ebill values('a107','Ragini','17-sep-2018',500);
insert into ebill values('a108','Rosy','19-mar-2018',600);
insert into ebill values('a109','Rajatha','21-nov-2018',670);
insert into ebill values('a110','Radhika','10-dec-2018',675);

1. Check the structure of table and note your observation.


desc ebill;

2. Add two fields to the table,


BILLAMT NUMBER(6,2) and DUEDATE DATE

alter table ebill add(billamt number(6,2), duedate date);

www.gkmvkalyan.blogspot.com
II PUC Computer Science Lab Manual Page 50 of 88

3. Compute the bill amount for each customer as per the following rules.
a. MINAMT Rs. 50
b. First 100 units Rs 4.50/Unit
c. >100 units Rs. 5.50/Unit

a) update ebill set billamt=50;

b) update ebill set billamt=billamt+unitsused*4.5 where


unitsused<100;

c) update ebill set billamt=billamt+(100*4.5)+ (unitsused-


100)*5.5 where unitsused>100;

4. Compute due date as BILLING_DATE + 15 Days

update ebill set duedate=billdate+15;

5. List all the bills generated.


select * from ebill;

www.gkmvkalyan.blogspot.com
II PUC Computer Science Lab Manual Page 51 of 88

SQL-2, Create a student database and compute the result

Create a table for class of students with the following fields.


Field Name Type
SID NUMBER(4)
SNAME VARCHAR2(25)
SUB1 NUMBER(3)
SUB2 NUMBER(3)
SUB3 NUMBER(3)
SUB4 NUMBER(3)
SUB5 NUMBER(3)
SUB6 NUMBER(3)

drop table student;

create table student(sid number(4),


sname varchar(25),
sub1 number(3),
sub2 number(3),
sub3 number(3),
sub4 number(3),
sub5 number(3),
sub6 number(3));

1. Add records into the table for 10 students for Student ID, Student Name
and marks in 6 subjects using INSERT command.
insert into student values(101,'Rama',99,85,97,96,92,96);
insert into student values(102,'Reena',91,82,67,86,62,76);
insert into student values(104,'Deepa',60,55,47,36,72,65);
insert into student values(109,'lokesh',40,45,35,60,35,35);
insert into student values(106,'Roja',15,25,47,36,42,36);
insert into student values(107,'Harish',55,57,57,56,52,56);
insert into student values(105,'Humera',19,15,27,16,12,26);
insert into student values(110,'Rani',69,65,67,66,62,68);
insert into student values(103,'Sheebha',59,75,77,65,52,69);
insert into student values(108,'Ramaya',23,25,57,56,52,56);

2. Display the description of the fields in the table using DESC command.
desc student;

www.gkmvkalyan.blogspot.com
II PUC Computer Science Lab Manual Page 52 of 88

3. Alter the table add TOTAL, PERCENTAGE and RESULT.


alter table student add(total number(3), percentage number(5,2),
result varchar(5));

4.Calculate Total Marks and Percentage of Marks.

update student set total =sub1+sub2+sub3+sub4+sub5+sub6;

update student set percentage=total/6;

5. Compute the RESULT as “Pass” by checking if the student has scored


more than 35 marks in each subject.

update student set result='Pass' where sub1>=35 and sub2>=35 and


sub3>=35 and sub4>=35 and sub5>=35 and sub6>=35;

6. Compute the RESULT as “FAIL” by checking if the student has scored


less than35 marks in each subject.

update student set result='Fail' where sub1<35 or sub2<35 or sub3<35


or sub4<35 or sub5<35 or sub6<35;

7. List the content of the table


select * from student;

www.gkmvkalyan.blogspot.com
II PUC Computer Science Lab Manual Page 53 of 88

8.Count the number of students failed.

select count(*) from student where result='Fail';

9.Count the number of students passed.

select count(*) from student where result='Pass;

10. List the number of students who have failed.

select * from student where result='Fail'

11. List the number of students who have passed.

select * from student where result='Pass';

www.gkmvkalyan.blogspot.com
II PUC Computer Science Lab Manual Page 54 of 88

12. sort the table according to Student ID.

select * from student order by sid;

******

www.gkmvkalyan.blogspot.com
II PUC Computer Science Lab Manual Page 55 of 88

17. Write a program to perform push items into the stack.

#include<iostream.h>
#include<conio.h>
#define MAX 3
class stack
{
private:
int top,ele,s[MAX],i;
public:
stack()
{
top=-1;
}
void push()
{
if(top == MAX)
{
cout<<"Stack full"<<endl;
return;
}
top=top+1;
cout<<"enter the element to insert"<<endl;
cin>>ele;
s[top]=ele;
}
void display()
{
if(top!=-1)
{
cout<<"stack elements are "<<endl;
for(i=top-1; i>=0; i--)
{
cout<<s[i]<<endl;
}
}
else

www.gkmvkalyan.blogspot.com
II PUC Computer Science Lab Manual Page 56 of 88

cout<<"stack is empty"<<endl;
}
};
void main()
{
stack S;
char choice;
clrscr();
do
{
S.push();
cout<<"Do you wish to continue(y/n) "<<endl;
cin>>choice;
}
while(choice=='y');
S.display();
getch();
}

Output

enter the element to insert


23
Do you wish to continue(y/n)
y
enter the element to insert
45
Do you wish to continue(y/n)
y
enter the element to insert
56
Do you wish to continue(y/n)
y
enter the element to insert
12
Do you wish to continue(y/n)

www.gkmvkalyan.blogspot.com
II PUC Computer Science Lab Manual Page 57 of 88

y
Stack full
Do you wish to continue(y/n)
n
stack elements are
56
45
23

www.gkmvkalyan.blogspot.com
II PUC Computer Science Lab Manual Page 58 of 88

18. Write a program to pop elements from the stack.

#include<iostream.h>
#include<conio.h>
class stack
{
private:
int top,ele,s[20],i;
public:
stack()
{
top=-1;
}
void push()
{
top=top+1;
cout<<"Enter the element to insert"<<endl;
cin>>ele;
s[top]=ele;
}
void pop()
{
if(top==-1)
cout<<"Stack underflow"<<endl;
else
cout<<"Element deleted is "<<s[top]<<endl;
top=top-1;
}
void display()
{
if(top==-1)
cout<<”Stack underflow”<<endl;
else
cout<<"Stack elements are"<<endl;
for(i=top;i>=0;i--)
{

www.gkmvkalyan.blogspot.com
II PUC Computer Science Lab Manual Page 59 of 88

cout<<s[i]<<endl;
}
}
};
void main()
{
char choice;
int option;
stack s;
clrscr();
do
{
cout<<"Enter:"<<endl;
cout<<"1->Push"<<endl;
cout<<"2->Pop"<<endl;
cout<<"3->Display"<<endl;
cin>>option;
switch(option)
{
case 1:s.push();
break;

www.gkmvkalyan.blogspot.com
II PUC Computer Science Lab Manual Page 60 of 88

case 2:s.pop();
break;
case 3:s.display();
break;
default:cout<<"Invalid option"<<endl;
break;
}
cout<<"Do you wish to continue(y/n)"<<endl;
cin>>choice;
}while(choice=='y');
getch();
}

OUTPUT

www.gkmvkalyan.blogspot.com
II PUC Computer Science Lab Manual Page 61 of 88

19. Write a program to perform enqueue and dequeue.


#include<iostream.h>
#include<conio.h>
#define max 20
class queue
{
private:
int front,rear,ele,q[20],i;
public:
void queue()
{
front=0;
rear=-1;
}
void enque()
{
rear=rear+1;
cout<<"Enter the element to insert in queue"<<endl;
cin>>ele;
q[rear]=ele;
}
void deque()
{
if(front>rear)
cout<<"Queue underflow"<<endl;
else
cout<<"Element deleted from queue is "<<q[front]<<endl;
front=front+1;
}
void display()
{
if(front>rear)
cout<<"Queue underflow"<<endl;
else
cout<<"Elements of queue are:"<<endl;
for(i=front;i<=rear;i++)
{

www.gkmvkalyan.blogspot.com
II PUC Computer Science Lab Manual Page 62 of 88

cout<<q[i]<<" ";
}
}
};
void main()
{
char choice;
int option;
queue q;
clrscr();
do
{
cout<<"Enter:"<<endl;
cout<<"1->Enque"<<endl;
cout<<"2->Deque"<<endl;
cout<<"3->Display"<<endl;
cin>>option;
switch(option)
{
case 1:q.enque();
break;
case 2:q.deque();
break;
case 3:q.display();
break;
default:cout<<"Invalid option"<<endl;
break;
}
cout<<"Do you wish to continue(y/n)"<<endl;
cin>>choice;
}while(choice=='y');
getch();
}

www.gkmvkalyan.blogspot.com
II PUC Computer Science Lab Manual Page 63 of 88

OUTPUT

www.gkmvkalyan.blogspot.com
II PUC Computer Science Lab Manual Page 64 of 88

20. Write a program to create a linked list and appending nodes.


#include<iostream.h>
#include<conio.h>
class linked_list
{
private:
int ele;
struct node
{
int data;
node *link;
}*start,*newnode,*temp;
public:
linked_list()
{
start=NULL;
}
void append()
{
cout<<"Enter element to insert"<<endl;
cin>>ele;
newnode=new node;
newnode->data=ele;
newnode->link=NULL;
if(start==NULL)
{
start=newnode;
cout<<ele<<" is inserted"<<endl;
}
else
{
temp=start;
while(temp->link!=NULL)
temp=temp->link;
temp->link=newnode;

www.gkmvkalyan.blogspot.com
II PUC Computer Science Lab Manual Page 65 of 88

cout<<ele<<" is inserted"<<endl;
}
}
void display()
{
if(start==NULL)
{
cout<<"Linked list is empty"<<endl;
return;
}
cout<<"Linked list contains"<<endl;
temp=start;
while(temp!=NULL)
{
cout<<temp->data<<"->";
temp=temp->link;
}
cout<<"NULL"<<endl;
}
};
void main()
{
char choice;
int option;
linked_list l;
clrscr();
do
{
cout<<"Enter:"<<endl;
cout<<"1->Append"<<endl;
cout<<"2->Display"<<endl;
cin>>option;
switch(option)
{
case 1:l.append();
break;
case 2:l.display();

www.gkmvkalyan.blogspot.com
II PUC Computer Science Lab Manual Page 66 of 88

break;
default:cout<<"Invalid choice"<<endl;
break;
}
cout<<"Do you wish to continue(y/n):";
cin>>choice;
}while(choice=='y');
getch();
}

OUTPUT

www.gkmvkalyan.blogspot.com
II PUC Computer Science Lab Manual Page 67 of 88

21. Generate the Employee details and compute the salary based on the
department.
Create the following table EMPLOYEE.
Field Name Type
EMP_ID NUMBER(4)
DEPT_ID NUMBER(2)
EMP_NAME VARCHAR2(25)
EMP_SALARY NUMBER(5)

Create another table DEPARTMENT.


Field Name Type
DEPT_ID NUMBER(2)
DEPT_NAME VARCHAR2(20)
SUPERVISOR VARCHAR2(20)

Assume the DEPARTMENT names as Purchase (Id-01), Accounts (Id-02),


Sales (Id-03), and Apprentice (Id-04)

Enter 10 rows of data for table EMPLOYEE and 4 rows of data for
DEPARTMENT table.

Write the SQL statements for the following:


1. Find the names of all employees who work for the Accounts department.
2. How many employees work for Accounts department?
3. What are the Minimum, Maximum and Average salary of employees
working for Accounts department?
4. List the employees working for particular supervisor.
5. Retrieve the department names for each department where only one
employee works.
6. Increase the salary of all employees in the sales department by 15%.
7. Add a new Colum to the table EMPLOYEE called BONUS NUMBER (5) and
compute 5% ofthe salary to the said field.
8. Delete all the rows for the employee in the Apprentice department.

www.gkmvkalyan.blogspot.com
II PUC Computer Science Lab Manual Page 68 of 88

First we have to create two tables, GKEMP and GKDEPT

create table gkdept(deptid number(2) primary key,


dname varchar(20),
supervisor varchar(20));

create table gkemp(empid number(4) primary key,


deptid number(2) references gkdept(deptid),
ename varchar(25),
esalary number(5));

Assume the DEPARTMENT names as Purchase (Id-01), Accounts (Id-02),


Sales (Id-03), and Apprentice (Id-04)
Enter 10 rows of data for table EMPLOYEE and 4 rows of data for
DEPARTMENT table.

insert into gkdept values(01,'PURCHASE', 'RAMA');


insert into gkdept values(02,'ACCOUNTS', 'SHEEBHA');
insert into gkdept values(03,'SALES', 'LOKESH');
insert into gkdept values(04,'APPRENTICE', 'DEEPA');

insert into gkemp values(101, 01, 'ARUN', 15000);


insert into gkemp values(104, 02, 'MOHAN', 20000);
insert into gkemp values(105, 03, 'SUMAN', 22000);
insert into gkemp values(106, 02, 'SUSHMA', 18000);
insert into gkemp values(109, 01, 'VARSHA', 22300);
insert into gkemp values(110, 02, 'VINUTHA', 15000);
insert into gkemp values(102, 02, 'KAVYA', 21300);
insert into gkemp values(107, 03, 'AKASH', 18200);
insert into gkemp values(108, 04, 'ROSY', 12000);
insert into gkemp values(103, 02, 'DEEPAK', 24000);

select * from gkdept;

www.gkmvkalyan.blogspot.com
II PUC Computer Science Lab Manual Page 69 of 88

select * from gkemp;

Find the names of all employees who work for the Accounts department?
select * from gkemp where deptid=(select deptid from gkdept where
dname='ACCOUNTS');

How many employees work for Accounts department?


select count(*) from gkemp where deptid=(select deptid from gkdept
where dname='ACCOUNTS');

www.gkmvkalyan.blogspot.com
II PUC Computer Science Lab Manual Page 70 of 88

What are the Minimum, Maximum and Average salary of employees


working for Accountsdepartment?
select max(esalary),min(esalary),avg(esalary) from gkemp where
deptid=(select deptid from gkdept where dname='ACCOUNTS');

List the employees working for particular supervisor.


select * from gkemp where deptid=(select deptid from gkdept where
supervisor ='SHEEBHA');

Retrieve the department names for each department where only one
employee works.
select dname from gkdept where deptid in (select deptid from gkemp
group by deptid having count(*)=1);

Increase the salary of all employees in the sales department by 15%.


update gkemp set esalary=esalary + 15 * esalary/100 where
deptid=(select deptid from gkdept where dname='SALES');

1 rows updated

Add a new Colum to the table EMPLOYEE called BONUS NUMBER (5) and
compute 5% of the salary to the said field.
Alter table gkemp add(bonus number(5));

www.gkmvkalyan.blogspot.com
II PUC Computer Science Lab Manual Page 71 of 88

update gkemp set bonus = 5*esalary/100;


Select * from gkemp;

8. Delete all the rows for the employee in the Apprentice department.
delete from gkemp where deptid=(select deptid from gkdept where
dname='APPRENTICE');

1 row(s) deleted

www.gkmvkalyan.blogspot.com
II PUC Computer Science Lab Manual Page 72 of 88

22. Create database for the bank transaction.


1. Create a table for customer

drop table customer;

create table customer(cno number(3) primary key,


cname varchar(20),
caddress varchar(50),
phone number(10));

2. Create a table bank.


drop table bank;

create table bank(accno number(4) not null,


trnsamnt number(8,2),
trnsdate date,
trnstype char,
cno number(3) references customer(cno));

3. Insert data values into customers table


insert into customer values(101,'Rama','Bangalore',9875412301);
insert into customer values(102,'Sheeba','Tamil Nadu',9875412101);
insert into customer values(103,'Lokesh','Mysore',9875412401);

4. Insert data values for bank table


insert into bank values(8001,50000.00,'12-Jan-2019','C',101);
insert into bank values(8002,80000.00,'14-Jan-2019','D',102);
insert into bank values(8003,45000.00,'12-Feb-2019','C',103);
insert into bank values(8003,5000.00,'12-Feb-2019','D',101);

5. to display all records from customer table


select * from customer;

www.gkmvkalyan.blogspot.com
II PUC Computer Science Lab Manual Page 73 of 88

6. to display all records from bank table.


select * from bank;

7. To display all records from bank whose transaction date is 12-Feb-2019.


select * from bank where trnsdate='12-Feb-2019';

8. To join two tables


select accno,customer.cno,cname from customer,bank
where customer.cno=bank.cno;

9.Display records from customers whose name starts with 'S'


select * from customer where cnamelike'L%';

10. display today’s date.


select sysdate from dual;

www.gkmvkalyan.blogspot.com
II PUC Computer Science Lab Manual Page 74 of 88

www.gkmvkalyan.blogspot.com
II PUC Computer Science Lab Manual Page 75 of 88

www.gkmvkalyan.blogspot.com
II PUC Computer Science Lab Manual Page 76 of 88

www.gkmvkalyan.blogspot.com
II PUC Computer Science Lab Manual Page 77 of 88

www.gkmvkalyan.blogspot.com
II PUC Computer Science Lab Manual Page 78 of 88

www.gkmvkalyan.blogspot.com
II PUC Computer Science Lab Manual Page 79 of 88

www.gkmvkalyan.blogspot.com
II PUC Computer Science Lab Manual Page 80 of 88

www.gkmvkalyan.blogspot.com
II PUC Computer Science Lab Manual Page 81 of 88

www.gkmvkalyan.blogspot.com
II PUC Computer Science Lab Manual Page 82 of 88

www.gkmvkalyan.blogspot.com
II PUC Computer Science Lab Manual Page 83 of 88

www.gkmvkalyan.blogspot.com
II PUC Computer Science Lab Manual Page 84 of 88

www.gkmvkalyan.blogspot.com
II PUC Computer Science Lab Manual Page 85 of 88

www.gkmvkalyan.blogspot.com
II PUC Computer Science Lab Manual Page 86 of 88

www.gkmvkalyan.blogspot.com
II PUC Computer Science Lab Manual Page 87 of 88

www.gkmvkalyan.blogspot.com
II PUC Computer Science Lab Manual Page 1 of 88

www.gkmvkalyan.blogspot.com

You might also like