2nd Puc Lab Manual Dudda
2nd Puc Lab Manual Dudda
Program Page
Program Name
No No
SECTION- A (C++ AND DATA STRUCTURES)
03 Write a C++ program to delete an element from an array from a given position. 05
Write a C++ program to sort the element of an array in ascending order using
04 07
insertion sort.
Write a C++ program to search for a given element in an array using binary search
05 method. 09
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
06 11
result.
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.
07 13
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.
Write a C++ program to find the area of square/ rectangle/ triangle using function
08 overloading. 15
Program Page
Program Name
No No
SECTION – B (SQL)
PROGRAM 1:
#include<iostream.h>
#include<conio.h>
class freq
{
private:
int a[10], n, ele, counter;
public: void INPUT( );
void FINDFREQ( );
void OUTPUT( );
};
void freq::INPUT( )
{
cout<<"Enter the size of the array:"<<endl;
cin>>n;
cout<<"Enter the array elements:"<<endl;
for(int i=0; i<n; i++)
cin>>a[i];
cout<<"Enter the element to find the frequency"<<endl;
cin>>ele;
}
void freq::FINDFREQ( )
{
counter=0;
for(int i=0; i<n; i++)
if(ele == a[i])
counter++;
}
void freq::OUTPUT( )
{
if(counter > 0)
cout<<frequency of "<<ele<<”is “<<counter;
else
cout<<ele<<"not found";
}
int main( )
{
freq f;
f.INPUT( );
f.FINDFREQ( );
f.OUTPUT( );
getch( );
return 0;
}
OUTPUT 1:
OUTPUT 2:
PROGRAM 2
#include<iostream.h>
#include<conio.h>
#include<stdlib.h>
class ins
{
private: int a[10], n, pos, ele, i;
public: void INPUT( );
void INSERT( );
void OUTPUT( );
};
void ins::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 ins::INSERT( )
{
if(pos>n)
{
cout<<"Out of array limits!!!";
getch( );
exit(0);
}
else
{
for(i=n; i>=pos; i--)
a[i+1] = a[i];
a[pos] = ele;
n = n+1;
}
}
void ins::OUTPUT( )
{
cout<<"Array elements after insertion are:"<<endl;
for(i=0; i<n; i++)
cout<<a[i]<<" ";
}
int main( )
{
ins i;
i.INPUT( );
i.INSERT( );
i.OUTPUT( );
getch( );
return 0;
}
OUTPUT 1:
OUTPUT 2:
PROGRAM 3
#include<iostream.h>
#include<conio.h>
class del
{
private: int a[10], n, pos, i;
public:
void INPUT( );
void DELETE( );
void OUTPUT( );
};
void del::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 delete an element: ";
cin>>pos;
}
void del::DELETE( )
{
if(pos>n)
{
cout<<"Out of array limits ";
getch( );
exit(0);
}
else
{
for(i=pos-1; i<n; i++)
a[i] = a[i+1];
n = n-1;
}
}
void del::OUTPUT( )
{
cout<<"After deletion the array elements are"<<endl;
for(i=0; i<n; i++)
cout<<a[i]<<" ";
}
int main( )
{
del d;
d.INPUT( );
d.DELETE( );
d.OUTPUT( );
getch( );
return 0;
}
OUTPUT 1:
OUTPUT 2:
PROGRAM 4
#include<iostream.h>
#include<conio.h>
#include<stdlib.h>
class sort
{
private: int a[10], n, i;
public:
void INPUT( );
void INSORT( );
void OUTPUT( );
};
void sort::INPUT( )
{
cout<<"Enter the size of the array:"<<endl;
cin>>n;
cout<<"Enter the elements for the array: ";
for(i=0; i<n; i++)
cin>>a[i];
}
void sort::INSORT( )
{
int j, temp;
for(i=1; i<n; i++)
{
j = i;
while(j >= 1)
{
if(a[j] < a[j-1])
{
temp = a[j];
a[j] = a[j-1];
a[j-1] = temp;
}
j = j--;
}
}
}
void sort::OUTPUT( )
{
cout<<"Sorted List is:"<<endl;
int main( )
{
sort s;
s.INPUT( );
s.INSORT( );
s.OUTPUT( );
getch( );
return 0;
}
OUTPUT 1:
PROGRAM 5
Write a C++ program to search for a given element in an array using binary
search method.
#include<iostream.h>
#include<conio.h>
class bs
{
private: int a[10], n, ele, loc, beg, end, mid, i;
public:
void INPUT( );
void SEARCH( );
void OUTPUT( );
};
void bs::INPUT( )
{
cout<<"Enter the size of the array:"<<endl;
cin>>n;
cout<<"Enter the array elements in sorted order: ";
for(i=0; i<n; i++)
cin>>a[i];
cout<<"Enter the element to search: ”;
cin>>ele;
}
void bs::SEARCH( )
{
loc = -1;
beg = 0;
end = n-1;
while(beg <= end)
{
mid = (beg+end)/2;
if(ele == a[mid])
{
loc = mid+1; break;
}
Bapu Composite PU College 9|Page
C++ II PUC-Cs
void bs::OUTPUT( )
{
if(loc == -1)
cout<<ele<<" Element does not exist." ;
else
cout<<ele<<" Found at Location:"<<loc;
}
int main( )
{
bs s;
s.INPUT( );
s.SEARCH( );
s.OUTPUT( );
getch( );
return 0;
}
OUTPUT 1:
OUTPUT 2:
PROGRAM 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.
#include<iostream.h>
#include<conio.h>
class simple
{
private:
float p,t,r,si;
public: void INPUT( );
void COMPUTE( );
void OUTPUT( );
};
void simple::INPUT( )
{
cout<<"Enter the Principal, Rate and Time"<<endl;
cin>>p>>r>>t;
}
void simple::COMPUTE( )
{
si=(p * t * r)/100;
}
void simple::OUTPUT( )
{
cout<<"Principal = "<<p<<endl;
cout<<"Time = "<<t<<endl;
cout<<"Rate = "<<r<<endl;
cout<<"Simple Interest = "<<si<<endl;
}
int main( )
{
simple s;
s.INPUT( );
s.COMPUTE( );
s.OUTPUT( );
getch( );
return 0;
}
OUTPUT 1:
OUTPUT 2:
PROGRAM 7
#include<iostream.h>
#include<conio.h>
#include<math.h>
#include<process.h>
class quad
{
private: int a, b, c;
float d, r1, r1;
public:
void INPUT( );
void COMPUTE( );
void OUTPUT( );
};
void quad::INPUT( )
{
cout<<"Enter the values for a, b, c"<<endl;
cin>>a>>b>>c;
}
void quad::COMPUTE( )
{
d = b*b-4*a*c;
if(d= =0)
{
cout<<”Roots are equal”<<endl;
r1= b/(2*a);
r2= b/(2*a);
}
else if(d>0)
{
else
{
cout<<"Imaginary Roots..."<<endl;
exit(0);
}
}
void quad::display( )
{
cout<<"Root1="<<r1<<endl;
cout<<"Root1="<<r2<<endl;
}
int main( )
{
quad q;
q.INPUT( );
q.COMPUTE( );
q.OUTPUT( );
getch( );
return 0;
}
OUTPUT 1:
OUTPUT 2:
OUTPUT 3:
PROGRAM 8
int main()
{
float s1,s2,s3;
int choice;
fo f;
while(1)
{
cout<<"1.To find area of square"<<endl;
cout<<"2.To find area of rectangle"<<endl;
cout<<"3.To find the area of triangle"<<endl;
cout<<"4.Exit"<<endl;
cout<<"Enter your Choice:"<<endl;
cin>>choice;
switch(choice)
{
case 1: cout<<"Enter the input for square"<<endl;
cin>>s1;
cout<<"Area of Square= "<<f.area(s1)<<endl;
break;
}
getch();
return 0;
}
OUTPUT:
PROGRAM 9
#include<iostream.h>
#include<conio.h>
inline int CUBE(int a)
{
return a*a*a;
}
int main()
{
int n;
cout<<"Enter the input number"<<endl;
cin>>n;
cout<<"Cube of "<<n<<" = "<<CUBE(n);
getch( );
return 0;
}
OUTPUT 1:
OUTPUT 2:
PROGRAM 10
#include<iostream.h>
#include<conio.h>
#include<math.h>
class series
{
private:
int sum, x, n;
public:
series(int y, int m)
{
sum = 1;
x = y;
n = m;
}
int SS( );
};
int series::SS( )
{
for(int i=1; i<=n; i++)
sum=sum+pow(x ,i);
return sum;
}
int main()
{
int x , n;
cout<<"Enter the value for Base(X)="<<endl;
cin>>x;
cout<<"Enter the value for Power(n)"<<endl;
cin>>n;
cout<<s2.SS( );
getch( );
return 0;
}
OUTPUT 1:
OUTPUT 2:
PROGRAM 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.
#include<iostream.h>
#include<conio.h>
class student
{
private:
int roll;
char name[20];
public:
void INPUT1( )
{
cout<<"Enter the Roll Number: ";
cin>>roll;
cout<<"Enter the Student Name:";
cin>>name;
}
void OUTPUT1( )
{
cout<<"Roll Number: "<<roll<<endl;
cout<<"Student Name: "<<name<<endl;
}
};
int main( )
{
marks m;
m.INPUT1( );
m.INPUT2( );
m.OUTPUT1( );
m.OUTPUT2( );
getch( );
return 0;
}
OUTPUT 1:
PROGRAM 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 student
{
private: int regno;
char name[20];
float fees;
public: void INPUT( );
void OUTPUT( );
};
void student::INPUT( )
{
cout<<"Enter the Register Number:"<<endl;
cin>>regno;
cout<<"Enter the Student Name:"<<endl;
cin>>name;
cout<<"Enter the Fees:"<<endl;
cin>>fees;
}
void student::OUTPUT( )
{
cout<<"Register Number : "<<regno<<endl;
cout<<"Student Name : "<<name<<endl;
cout<<"Fees : "<<fees<<endl;
}
int main( )
{
student s, *sptr;
sptr=&s;
s->INPUT( );
s->OUTPUT( );
getch( );
return 0;
}
OUTPUT 1:
OUTPUT 2:
PROGRAM 13:
#include<iostream.h>
#include<conio.h>
#include<stdlib.h>
#define MAX 3
class stack
{
private:
int s[MAX], top;
public:
stack( )
{
top = -1;
}
void PUSH(int );
void OUTPUT( );
};
void stack::PUSH(int item)
{
if(top == MAX-1)
cout<<"Stack is Full<<endl;
else
{
top++;
s[top]=item;
}
}
void stack::OUTPUT( )
{
if(top == -1)
cout<<"Empty Stack!"<<endl;
else
{
for(int i=0; i<=top; i++)
cout<<endl<<s[i];
PROGRAM 14:
#include<iostream.h>
#include<conio.h>
#include<stdlib.h>
#define MAX 3
class stack
{
private: int s[MAX], top;
public: stack()
{
top = -1;
}
void PUSH(int );
int POP( );
void OUTPUT( );
};
int stack::POP()
{
int item; if(top == -1)
cout<<"Stack Empty!!!...Can't POP"<<endl;
else
{
item = s[top]; top--; }
return item;
}
void stack::OUTPUT( )
{
if(top == -1)
cout<<"Stack Empty!!!"<<endl;
else
{
for(int i=0; i<=top; i++)
cout<<endl<<s[i];
cout<<"-->top element"<<endl;
}
}
int main( )
{
stack s;
s.POP( );
s.PUSH(20);
s.PUSH(30);
s.PUSH(40);
s.OUTPUT( );
POP( );
s.OUTPUT( );
getch();
return 0;
OUTPUT:
PROGRAM 15:
Write a C++ program to perform Enqueue and Dequeue.
#include<iostream.h>
#include<conio.h>
#include<stdlib.h>
#define MAX 3
class que
{
private: int q[MAX],front,rear;
public: que()
{
front = -1;
rear = -1;
}
void ENQ(int );
void DEQ( );
void OUTPUT( );
};
void que::ENQ(int item)
{
if(rear == MAX-1)
{
cout<<"Queue is full.<<endl;
getch( );
exit(0);
}
if(front == -1)
{
front = 0;
rear = 0;
}
else
{
rear++;
q[rear] = item;
cout<<"Item Inserted: "<<item<<endl;
}
}
void que::DEQ( )
{
int item;
if(front == -1)
{
cout<<"Queue is Empty"<<endl;
}
item = q[front];
if(front == rear)
{
front = -1;
rear = -1;
}
else
front++;
cout<<item<<” is deleted from queue<<endl;
}
void que::OUTPUT( )
{
if(front == -1)
cout<<"Queue is Empty!!!"<<endl;
else
for(int i=front; i<=rear; i++)
cout<<q[i]<<endl;
}
int main()
{
que q;
q.ENQ(20);
q.ENQ(30);
q.ENQ(40);
q.OUTPUT( );
q.DEQ( );
q.DEQ( );
q.OUTPUT( );
getch( );
return 0;
}
OUTPUT:
STRUCTURED QUERY
LANGUAGE (SQL)
PROGRAM 1:
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.
Solution:
First we have to create the table EBILL using CREATE TABLE command.
SQL> INSERT INTO EBILL VALUES ('EH 1003', 'ARUN KUMAR' ,'12-MAR-16',98);
SQL> INSERT INTO EBILL VALUES ('EH 2005', 'NAVEEN' ,'14-MAR-16',108);
SQL> INSERT INTO EBILL VALUES ('EH 2007','VARUN' ,'18-FEB-16',157);
SQL> INSERT INTO EBILL VALUES ('EH 3009', 'DAVID' ,'11-APR-16',77);
SQL> INSERT INTO EBILL VALUES ('EH 3010', 'JHON' ,'01-MAR-16',89);
SQL> INSERT INTO EBILL VALUES ('EH 3013', 'AKSHAY' ,'02-FEB-16',68);
SQL> INSERT INTO EBILL VALUES ('EH 1010', 'CHANDRU' ,'12-MAR-16',108);
SQL> INSERT INTO EBILL VALUES ('EH 1008', 'GHANAVI' ,'12-MAR-16',132);
SQL> INSERT INTO EBILL VALUES ('EH 2105', 'DRUVA' ,'12-MAR-16',87);
SQL> INSERT INTO EBILL VALUES ('EH 3041', 'SHREYA' ,'12-MAR-16',127);
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
COMMAND 2:
PROGRAM 2:
Solution:
First we have to create the table CLASS using CREATE TABLE command.
1. Add records into the table for 10 students for Student ID, Student Name and marks in 6
subjects using INSERT command.
SQL> INSERT INTO CLASS VALUES (1401, 'PAWAN', 56, 36, 56, 78, 44, 67);
SQL>INSERT INTO CLASS VALUES (1411, 'RAJESH', 100,100,96,100,100,100);
SQL>INSERT INTO CLASS VALUES (1412, 'KARAN', 60,30,45,45,36,49);
SQL>INSERT INTO CLASS VALUES (1403, 'SACHIN', 56,60,72,57,78,67);
SQL>INSERT INTO CLASS VALUES (1410, 'PRAKASH', 96,99,97,90,78,100);
SQL>INSERT INTO CLASS VALUES (1402, 'POOJA', 30,45,39,20,33,56);
SQL>INSERT INTO CLASS VALUES (1405, 'ASHWINI', 79,65,79,70,89,88);
SQL>INSERT INTO CLASS VALUES (1406, 'PRAJWAL', 100,90,100,89,90,100);
SQL>INSERT INTO CLASS VALUES (1404, 'BALU', 35,30,78,23,44,70);
SQL>INSERT INTO CLASS VALUES (1407, 'ESHWAR', 100,100,100,98,99,100);
2. Display the description of the fields in the table using DESC command.
4. Compute the RESULT as “PASS” or “FAIL” by checking if the student has scored more
than 35 marks in each subject.
12. List the students who have percentage greater than 60.
PROGRAM 3:
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(10)
EMP_SALARY NUMBER(5)
Create another table DEPARTMENT.
Field Name Type
DEPT_ID NUMBER(2)
DEPT_NAME VARCHAR2(10)
SUPERVISOR VARCHAR2(10)
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.
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% of
the salary to the said field.
8. Delete all the rows for the employee in the Apprentice department.
Solution:
To Insert 10 records into the table EMPLOYEE using INSERT INTO command.
SQL> INSERT INTO EMPLOYEE VALUES (101, 01, 'ARUN', 15000);
SQL> INSERT INTO EMPLOYEE VALUES (104, 02, 'MOHAN', 20000);
SQL> INSERT INTO EMPLOYEE VALUES (105, 03, 'SUMAN', 22000);
SQL> INSERT INTO EMPLOYEE VALUES (106, 02, 'SUSHMA', 18000);
SQL> INSERT INTO EMPLOYEE VALUES (109, 01, 'KUSHI', 22300);
SQL> INSERT INTO EMPLOYEE VALUES (110, 02, 'VIDHYA', 15000);
SQL> INSERT INTO EMPLOYEE VALUES (102, 02, 'KAVYA', 21300);
SQL> INSERT INTO EMPLOYEE VALUES (107, 03, 'AKASH', 18200);
SQL> INSERT INTO EMPLOYEE VALUES (108, 04, 'NAWAZ', 12000);
SQL> INSERT INTO EMPLOYEE VALUES (103, 02, 'DEEPAK', 24000);
To insert 4 records into the table DEAPRTMENT using the INSERT INTO command.
SQL>INSERT INTO DEPARTMENT VALUES (01, 'PURCHASE', 'KRISHNA');
SQL>INSERT INTO DEPARTMENT VALUES (02, 'ACCOUNTS', 'TANVEER');
SQL>INSERT INTO DEPARTMENT VALUES (03, 'SALES', 'SURYA');
SQL>INSERT INTO DEPARTMENT VALUES (04, 'APPRENTICE', 'HARSHA');
1. Find the names of all employees who work for the Accounts department.
3. What are the Minimum, Maximum and Average salary of employees working for
Accounts department?
5. Retrieve the department names for each department where only one employee works.
7. Add a 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.
ADVANCED HTML
PROGRAM 1:
<HEAD>
<TITLE>STUDY TIMETABLE</TITLE>
<STYLE>
</STYLE>
</HEAD>
<TABLE>
<TR>
<TH>DAYS</TH>
<TH>SUBJECTS</TH>
</TR>
Advanced HTML II PUC-Cs
<TR>
<TD>MONDAY</TD>
<TD>ENGLISH</TD>
<TD>5:00-6:00AM</TD>
<TD>9:00-4:00PM</TD>
<TD>6:30-8:30PM</TD>
<TD>9:30-11:30PM</TD>
</TR>
<TR>
<TD>TUESDAY</TD>
<TD>SANSKRIT</TD>
<TD>5:00-6:30AM</TD>
<TD>9:00-4:00PM</TD>
<TD>6:30-8:30PM</TD>
<TD>9:30-11:30PM</TD>
</TR>
<TR>
<TD>WEDNEDAY</TD>
<TD>5:00-6:30AM</TD>
<TD>9:00-4:00PM</TD>
<TD>6:30-8:30PM</TD>
<TD>9:30-11:30PM</TD>
</TR>
<TR>
<TD> ECONOMICS</TD>
<TD>5:00-6:30AM</TD>
<TD>9:00-4:00PM</TD>
<TD>6:30-8:30PM</TD>
<TD>9:30-11:30PM</TD>
</TR>
<TR>
<TD> FRIDAY</TD>
<TD> BUSINESS</TD>
<TD>5:00-6:30AM</TD>
<TD>9:00-4:00PM</TD>
<TD>6:30-8:30PM</TD>
<TD>9:30-11:30PM</TD>
</TR>
<TR>
<TD> ACCOUNTANCY</TD>
<TD>5:00-6:30AM</TD>
<TD>9:00-4:00PM</TD>
<TD>6:30-8:30PM</TD>
<TD>9:30-11:30PM</TD>
</TR>
</TABLE>
</BODY>
</HTML>
OUTPUT:
PROGRAM 2:
<HEAD>
<STYLE>
TABLE,TR,TH,TD
</STYLE>
</HEAD>
<CENTER>
<TABLE>
<TR>
<TH>STREAM</TH>
<TH>COMMERCE<INPUTTYPE="RADIO">SCIENCE<INPUT TYPE="RADIO">
</TR>
<TR>
<TH>STUDENT ID*</TH>
</TR>
<TR>
<TH>PASSWORD*</TH>
</TR>
<TR>
<TH>EMAIL ADDRESS*</TH>
</TR>
<TR>
<TH>MOBILE</TH>
</TR>
<TR>
<TH>FEED BACK*</TH>
<TH><TEXTAREA MAX
LENGTH="500"ROWS="10"COLUMN="50"></TEXTAREA></TH>
</TR>
<TR>
<TH><INPUT TYPE="SUBMIT"VALUE="SUBMIT"></TH>
<TH><INPUT TYPE="RESET"VALUE="RESET"></TH>
</TR>
</TABLE>
</FORM></CENTER>
</BODY>
</HTML>
OUTPUT: