2ND PUC COMPUTER SCIENCE LAB PROGRAMS



2nd puc computer science programs,2nd puc computer science lab manual,2nd puc computer science lab manual pdf download,2nd puc computer science lab manual download,2nd puc computer science lab manual html,2nd puc computer science practical programs,computer science lab manual class 12 pdf,computer science lab manual class 12 karnataka pdf,class 12 computer science practicals with solutions,computer science practical class 12 pdf,class 12 computer science practicals with solutions,
computer science practical class 12 pdf, 12th computer science practical book pdf download, class 12 computer science practicals with solutions,2nd puc cs lab manual pdf,2nd puc computer manual book,2nd puc html program,2nd puc computer science lab programs pdf,2nd puc lab manual computer science,computer science 2nd puc lab manual,computer science practical manual second puc
      


SECTION A
C++ AND DATA STRUCTURE

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

#include<iostream.h>
#include<conio.h>
class frequency
{
int a[10],n,i,ele;
public: void getdata();
            void putdata();
};
void frequency::getdata()
{
cout<<"Enter the size of an array";
cin>>n;
cout<<"Enter the elements\n";
for(i=0;i<n;i++)
cin>>a[i];
}
void frequency::putdata()
{
int count=0;
cout<<"Enter the element whose frequency is to be checked: ";
cin>>ele;
for(i=0;i<n;i++)
if(ele==a[i])
count++;
cout<<ele<<" has appeared "<<count<<" times";
}
void main()
{
frequency f;
clrscr();
f.getdata();
f.putdata();
getch();
}
Download this program
/* 2. Write a program to insert an element into an array at a given position.*/

#include<iostream.h>
#include<conio.h>
void main()
{
int a[10],i,n,ele,p;
cout<<"Enter the size of an array: ";
cin>>n;
cout<<"Enter the elements:\n";
for(i=0;i<n;i++)
cin>>a[i];
cout<<"Enter the element to be inserted: ";
cin>>ele;
cout<<"Enter the position (from 0 to "<<n<<")";
cin>>p;
if(p>n)
cout<<"Invalid Position";
else
{
for(i=n-1;i>=p;i--)
a[i+1]=a[i];
a[p]=ele;
n=n+1;
}
cout<<"Elements after insertion are:\n";
for(i=0;i<n;i++)
cout<<a[i];
getch();
}
Download this program
/* 3. Write a program to delete an element from an array from a given position.*/

#include<iostream.h>
#include<conio.h>
void main()
{
int a[10],i,n,ele,p;
clrscr();
cout<<"Enter the size of an array: ";
cin>>n;
cout<<"Enter the elements:\n";
for(i=0;i<n;i++)
cin>>a[i];
cout<<"Enter the position (from 0 to "<<n-1<<")";
cin>>p;
if(p>n-1)
cout<<"Invalid position";
else
{
ele=a[p];
for(i=p;i<n;i++)
a[i]=a[i+1];
n=n-1;
cout<<"Elements after deletion are:\n";
for(i=0;i<n;i++)
cout<<a[i];
}
getch();
}
Download this program
/* 4. Write a program to sort the elements of an array in ascending order using an insertion sort.*/

#include<iostream.h>
#include<conio.h>
void main()
{
int a[10],i,j,n,temp;
clrscr();
cout<<"Enter the size of an array: ";
cin>>n;
cout<<"Enter the elements:\n";
for(i=0;i<n;i++)
cin>>a[i];
for(i=1;i<n;i++)
{
temp=a[i];
j=i-1;
while(temp<a[j]&&j>=0)
{
a[j+1]=a[j];
j=j-1;
}
a[j+1]=temp;
}
cout<<"Sorted elements are:\n";
for(i=0;i<n;i++)
cout<<a[i];
getch();
}
Download this program
/* 5. Write a program to search for a given element in an array using Binary search method. */

#include<iostream.h>
#include<conio.h>
void main()
{
int a[10],i,n,ele,pos=-1,m,b,e;
clrscr();
cout<<"Enter the size of an array: ";
cin>>n;
cout<<"Enter the elements:\n";
for(i=0;i<n;i++)
cin>>a[i];
cout<<"Enter the search element: ";
cin>>ele;
b=0;
e=n-1;
while(b<=e)
{
m=(b+e)/2;
if(ele==a[m])
{
pos=m;
break;
}
else if(ele<a[m])
e=m-1;
else
b=m+1;
}
if(pos>=0)
cout<<"Location="<<pos;
else
cout<<"Search is unsuccessful";
getch();
}
Download this program
/* 6. Write a program to create a class with data member principal, 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 SI
{
int time;
float principal,rate;
public: void getdata()
            {
            cout<<"Enter the principal, time and rate of interest: \n";
            cin>>principal>>time>>rate;
            }
            float compute_si()
            {
            return(principal*time*rate/100.0);
            }
            void display()
            {
            cout<<"Simple Interest="<<compute_si();
            }
};
void main()
{
SI s;
clrscr();
s.getdata();
s.display();
getch();
}
Download this program
/* 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.
- if discriminant=0, print the roots that are equal
- if the discriminant is>0, print the real roots
- if the discriminant is<0, print that the roots are imaginary*/

#include<iostream.h>
#include<conio.h>
#include<math.h>
class quad
{
float x1,x2,imaginarypart,realpart,discriminant,a,b,c;
public: void getdata()
            {
            cout<<"Enter the values of a, b, c: ";
            cin>>a>>b>>c;
            discriminant=b*b-4*a*c;
            }
            void putdata()
            {
            if(discriminant>0)
            {
            x1=(-b+sqrt(discriminant))/(2*a);
            x2=(-b-sqrt(discriminant))/(2*a);
            cout<<"Roots are real and different:\n";
            cout<<"x1="<<x1<<"and x2="<<x2;
            }
            else if(discriminant==0)
            {
            x1=-b/(2*a);
            cout<<"Roots are real and equal\n";
            cout<<"x1=x2="<<x1;
            }
            else
            {
            realpart=-b/(2*a);
            imaginarypart=sqrt(-discriminant)/(2*a);
            cout<<"Roots are imaginary\n";
            cout<<realpart<<"+"<<imaginarypart<<"i"<<endl;
            cout<<realpart<<"-"<<imaginarypart<<"i";
            }
            }
};
void main()
{
quad q;
clrscr();
q.getdata();
q.putdata();
getch();
}
Download this program
/* 8. Program to find the area of a square/rectangle/triangle using function overloading.*/

#include<iostream.h>
#include<conio.h>
class function_overloading
{
public: int area(int a) // area of a square
            {
            return(a*a);
            }
            int area(int l,int w) // area of a rectangle
            {
            return(l*w);
            }
            double area(double b,double h)
            {
            return(0.5*b*h);
            }
};
void main()
{
function_overloading f;
clrscr();
cout<<"Area of square="<<f.area(5)<<endl;
cout<<"Area of rectangle="<<f.area(5,10)<<endl;
cout<<"Area of triangle="<<f.area(2.0,3.0);
getch();
}
Download this program
/* 9. Program to find the cube of a number using inline functions.*/

#include<iostream.h>
#include<conio.h>
inline int cube(int a)
{
return(a*a*a);
}
void main()
{
int x,y;
clrscr();
x=cube(5);
cout<<"Cube of 5="<<x<<endl;
y=cube(10);
cout<<"Cube of 10="<<y;
getch();
}
Download this program
/* 10. Write a program to find the sum of the series 1+x+x^2+...+x^n using constructors.*/

#include<iostream.h>
#include<conio.h>
class series
{
int x,n;
public: series(int x1,int n1)
            {
            x=x1;
            n=n1;
            }
            void display();
};
void series::display()
{
int sum=1;
for(int i=0;i<n;i++)
{
sum=sum*x;
sum=sum+1;
}
cout<<"Sum of the series 1+x+x^2+...+x^n="<<sum;
}
void main()
{
int x1,n1;
clrscr();
cout<<"Enter the value of x: ";
cin>>x1;
cout<<"Enter the value of n: ";
cin>>n1;
series s(x1,n1);
s.display();
getch();
}
Download this program
/* 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 the data members.*/

#include<iostream.h>
#include<conio.h>
class abc
{
int rollno;
char name[20];
public:
            void read()
            {
            cout<<"enter roll no and name"<<endl;
            cin>>rollno>>name;
            }
            void display()
            {
            cout<<"roll no:"<<rollno<<endl;
            cout<<"name:"<<name<<endl;
            }
};
class xyz:public abc
{
int m1;
int m2;
int t;
public:
            void read1()
            {
            cout<<"enter the first marks & second marks:";
            cin>>m1>>m2;
            t=m1+m2;
            }
            void display1()
            {
            cout<<"first marks="<<m1<<endl;
            cout<<"second marks="<<m2<<endl;
            cout<<"total marks="<<t<<endl;
            }
};
void main()
{
xyz ob;
clrscr();
ob.read();
ob.read1();
ob.display();
ob.display1();
getch();
}
Download this 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
{
int regno;
char name[20];
float fees;
public: void read();
            void display();
};
void student::read()
{
cout<<"enter the register number: ";
cin>>regno;
cout<<"enter the student name: ";
cin>>name;
cout<<"enter the fees: ";
cin>>fees;
}
void student::display()
{
cout<<"register number="<<regno<<endl;
cout<<"student name="<<name<<endl;
cout<<"student fees="<<fees;
}
void main()
{
student s,*sp;
sp=&s;
clrscr();
sp->read();
sp->display();
getch();
}
Download this program
/* 13. Write a program to perform push items into the stack.*/

#include<iostream.h>
#include<conio.h>
#include<stdlib.h>
#define N 5
void main()
{
int stack[N],i,choice=1,top=-1,ele;
clrscr();
while(choice)
{
cout<<"\nSTACK OPERATIONS\n\n";
cout<<"1.Push\n2.Display\n3.Exit\n";
cout<<"Enter your Choice:";
cin>>choice;
switch(choice)
{
case 1:cout<<"Enter the element to be pushed:";
cin>>ele;
if(top==N-1)
{
cout<<"Stack is Full";
getch();
exit(0);
}
else
{
cout<<ele<<" is inserted at "<<top+1;
top=top+1;
stack[top]=ele;
break;
}
case 2:cout<<"Content of Stack is:\n";
if(top==-1)
{
cout<<"Stack is Empty";
getch();
}
else
{
for(i=top;i>=0;i--)
cout<<"Stack["<<i<<"]="<<stack[i]<<endl;
break;
}
case 3:exit(0);
break;
default:cout<<"Invalid choice";
}
}
getch();
}
Download this program
/* 14. Write a program to pop elements from the stack.*/

#include<iostream.h>
#include<conio.h>
#include<stdlib.h>
#define N 5
void main()
{
int stack[N]={10,20,30,40,50};
int choice=1,ele,top=4,i;
clrscr();
while(choice)
{
cout<<"\nSTACK OPERATIONS:\n\n";
cout<<"\n1.Pop\n2.Display\n3.Exit\n";
cout<<"\nEnter your choice: ";
cin>>choice;
switch(choice)
{
case 1: if(top==-1)
            {
            cout<<"Stack is empty";
            getch();
            continue;
            }
            else
            {
            for(i=top;i>=0;i--)
            ele=stack[top];
            cout<<"The popped element is: "<<ele;
            top=top-1;
            }
            break;
case 2: if(top==-1)
            {
            cout<<"Stack is empty";
            getch();
            exit(0);
            }
            else
            {
            cout<<"Content of stack is:\n";
            for(i=top;i>=0;i--)
            cout<<"stack["<<i<<"]="<<stack[i]<<endl;
            }
            break;
case 3: exit(0);
default: cout<<"Invalid choice";
}
}
getch();
}
Download this program
/* 15. Write a program to perform enqueue and dequeue.*/

#include<iostream.h>
#include<conio.h>
#include<stdlib.h>
#define N 5
void main()
{
int q[N],front=-1,rear=-1,choice=1,item,i;
clrscr();
while(choice)
{
cout<<"\n QUEUE OPERATIONS:\n";
cout<<"\n1.INSERT\n2.DELETE\n3.DISPLAY\4.EXIT\n";
cout<<choice;
switch(choice)
{
case 1: if(rear==N-1)
            {
            cout<<"\nQueue is full";
            continue;
            }
            else
            {
            cout<<"Enter the element to be inserted: ";
            cin>>item;
            rear=rear+1;
            q[rear]=item;
            cout<<item<<" is inserted at q["<<rear<<"]="<<q[rear]<<endl;
            if(front==-1)
            front=front+1;
            }
            break;
case 2: if(front==rear)
            {
            front=-1;
            rear=-1;
            cout<<"\nQueue is empty";
            }
            else
            {
            item=q[front];
            cout<<"The element deleted from "<<front<<" position is "<<item;
            front=front+1;
            }
            break;
case 3: if(front==-1)
            {
            cout<<"\nQueue is empty\n";
            continue;
            }
            else
            {
            cout<<"\nStatus of Queue:\n";
            for(i=front;i<=rear;i++)
            cout<<"q["<<i<<"]="<<q[i]<<endl;
            }
            break;
case 4: exit(0);
            break;
default: cout<<"Invalid Choice";
}
}
}
getch();
}
Download this program
/* 16. Write a program to create a linked list and appending nodes.*/

#include<iostream.h>
#include<conio.h>
class linklist
{
struct Node
{
int data;
Node*link;
}*START;
public:linklist();
       void print();
       void Append(int num);
       void count();
};
linklist::linklist()
{
START=NULL;
}
void linklist::print()
{
if(START==NULL)
{
cout<<"linked list is empty\n";
return;
}
cout<<"\nlinked list contains";
Node*p=START;
while(p!=NULL)
{
cout<<p->data<<" ";
p=p->link;
}
}
void linklist::Append(int num)
{
Node *newNode;
newNode=new Node;
newNode->data=num;
newNode->link=NULL;
if(START==NULL)
{
START=newNode;
cout<<num<<"is inserted as the first node";
}
else
{
Node *p=START;
while(p->link!=NULL)
p=p->link;
p->link=newNode;
cout<<endl<<num<<"is inserted"<<endl;
}
}
void linklist::count()
{
Node*p;
int c=0;
for(p=START;p!=NULL;p=p->link)
c++;
cout<<endl<<"number of elements in the linked list="<<c<<endl;
}
void main()
{
linklist *obj=new linklist;
clrscr();
obj->print();
obj->Append(100);
obj->print();
obj->count();
obj->Append(200);
obj->print();
obj->count();
obj->Append(300);
obj->print();
obj->count();
getch();
}
Download this program
Section B
SQL

17. Generate the Electricity Bill for one consumer.

TABLE CREATION:
SQL>create table ebill(meter_no varchar(10),c_name varchar(25),bill_date date,units number(4));

i) VALUE INSERTION:

SQL>insert into ebill values(‘e1’,’raju’,’17-dec-2019’,46);

ii) CALCULATION OF ELECTRICITY BILL

          a)      alter table ebill add(bill_amt number(6,2),due_date date);
          b)      update ebill set bill_amt=100+units*4.10 where units<=100;
          c)      update ebill set bill_amt=100+100*4.10+(units-100)*5 where units>100;

iii) COMPUTE AND DISPLAY DUE DATE AS BILLING DATE+15 DAYS

      SQL>update ebill set due_date=bill_date+15;
SQL>select *from ebill;
Download this program 18. Create a student database and compute the result.

TABLE CREATION:

SQL>create table student(rollno number(3),name varchar(20),sub1 number(3),sub2 number(3) ,sub3 number(3),sub4 number(3) ,sub5 number(3),sub6 number(3));

i) VALUE INSERTION:

SQL> insert into student values(1,’deepak’,45,66,75,87,78,98);
SQL> insert into student values(2,’vani’,45,66,75,87,78,98);
SQL> insert into student values(3,’raju’,45,66,75,87,78,98);
SQL> insert into student values(4,’rakshit’,45,66,75,87,78,98);
SQL> insert into student values(5,’karthik’,45,66,75,87,78,98);

ii) CALCULATION OF TOTAL AND PERCENTAGE:

          a)      SQL>alter table student add(total number(3),percentage number(6,2),result varchar(10));
          b)      SQL>update student set total=sub1+sub2+sub3+sub4+sub5+sub6;
          c)      SQL>update student set percentage=total/6;

iii) COMPUTE RESULT:

           a)      SQL>update student set result=’pass’ where(sub1>=35 and sub2>=35 and sub3>=35 
                         and sub4>=35 and sub5>=35 and sub6>=35);
           b)      SQL>update student set result=’fail’ where(sub1<35 or sub2<35 or sub3<35 or sub4<35 
                          or sub5<35 or sub6<35);

iv) a) DISPLAY THE CONTENT OF THE TABLE:

SQL>select * from student; 

b) QUERY TO DISPLAY THE LIST OF STUDENTS WHO HAVE PASSED:

SQL>select * from student where result=’pass’; 

c) QUERY TO DISPLAY THE LIST OF STUDENTS WHO HAVE FAILED:

SQL>select *from student where result=’fail’; 

d) COUNT THE NUMBER OF STUDENTS WHO HAVE PASSED:
SQL>select count(*) from student where result=’pass’; 

e) COUNT NUMBER OF STUDENTS WHO HAVE FAILED:

SQL> select count(*) from student where result=’fail’; 

f) COUNT THE NUMBER OF STUDENTS SECURE PERCENTAGE GREATER THAN 60

SQL>select * from student where percentage>60;
Download this program 19. Generate the Employee details and compute the salary based on the department.

EMPLOYEE TABLE CREATION:

SQL>create table employee(empid number(4),ename varchar(20),dept_name varchar(20),doj date,salary number(6,2));

VALUE INSERTION:

SQL>insert into employee values(1,’ramesh’,’chemistry’,’1-jun-12’,15000);
SQL>insert into employee values(2,’deepak’,’computer’,’1-jun-14’,16000);
SQL>insert into employee values(3,’rahul’,’computer’,’1-jun-16’,18000);
SQL>insert into employee values(4,’gopal’,’physics’,’1-aug-19’,20000);
SQL>insert into employee values(5,’krishna’,’computer’,’1-sep-11’,35000);

i) FIND THE NAMES OF ALL EMPLOYEES WHO WORK FOR COMPUTER DEPARTMENT: 

a) SQl>select ename from employee where dept_name=’computer’; 

b)     HOW MANY EMPLOYEES WORK FOR COMPUTER DEPARTMENT:

SQL>select count(*) from employee where dept_name=’computer’; 

ii) USE OF AGGREGATE FUNCTIONS: 

a) SQL> select min(salary),max(salary),avg(salary) from employee where dept_name=’computer’; 
b) SQL>update employee set salary=salary+10*salary/100 where dept_name=’computer’; 
c) SQL>alter table employee add(commission number(6,2)); 
d) SQL>update employee set commission=5*salary/100; 
e) SQL>select * from employee;
Download this program 20. Create database for the bank transaction.

BANK TABLE CREATION:

SQL>create table bank(ac_number number(15),c_name varchar(20),ac_type char(2), balance number(15), dot date, t_amount number(15),t_type char(1)); 

VALUE INSERTION:

SQL>insert into bank values(123456,’shubham’,’sb’,9000,’18-dec-19’,100,’W’);
SQL>insert into bank values(123451,’shruti’,’ca’,111000,’10-aug-19’,1000,’D’);
SQL>insert into bank values(123452,’kamala’,’sb’,11000,’12-jun-19’,15000,’D’);
SQL>insert into bank values(123453,’sargun’,’ca’,15000,’18-jul-19’,100,’W’);
SQL>insert into bank values(123454,’prashant’,’ca’,150000,’19-oct-19’,1200,’W’);

i) FIND THE NAMES OF ALL CUSTOMERS WHOSE BALANCE AMOUNT IS MORE THAN 100000

SQL>select * from bank where balance>100000; 

ii) FIND THE NUMBER OF CUSTOMERS WHOSE BALANCE IS LESS THAN MINIMUN i.e. MINIMUM BALANCE IS 1000:

SQL>select count(*) from bank where balance <1000; 

iii) TRANSACTION:

SQL>update bank set balance=balance+t_amount where t_type=’D’;
SQL>update bank set balance=balance-t_amount where t_type=’W’;

iv) DISPLAY TRANSACTION ON A PARTICULAR DAY:

SQL>select * from bank where dot=’12-jun19’; 

v) DISPLAY ALL THE RECORDS OF SB ACCOUNT:

SQL>select * from bank where ac_type=’sb’;
Download this program
SECTION C
HTML

21. Write a HTML program to create a study time-table. 
<! 21. Write a HTML program to create a study time-table.>
<html>
<body>
<table border="2">
<tr>
<th>monday</th>
<th>tuesday</th>
<th>wednesday</th>
<th>thursday</th>
<th>friday</th>
<th>saturday</th>
</tr>

<tr>
<td>physics</td>
<td>chemistry</td>
<td>mathenatics</td>
<td>biology</td>
<td>kannada</td>
<td>sanskrit</td>
</tr>

<tr>
<td>english</td>
<td>hindi</td>
<td>computer science</td>
<td>mathematics</td>
<td>chemistry</td>
<td>physics</td>
</tr>

<tr>
<td>sanskrit</td>
<td>kannada</td>
<td>biology</td>
<td>physics</td>
<td>chemistry</td>
<td>mathematics</td>
</tr>

<tr>
<td>kannada</td>
<td>physics</td>
<td>mahthematics</td>
<td>biology</td>
<td>chemistry</td>
<td>mathematics</td>
</tr>
</table>
</body>
</html>
Download this program 22. Create an HTML program with table and form.

<!22. Create an HTML program with table and form.>
<html>
<body>
<h1><center>Application Form</center></h1>
<form>
First Name:<input type="text" value="ram"><br><br>
Last Name:<input type="text" value="kumar"><br><br>
Password:<input type="password"><br><br>
Hidden Field:<input type="hidden"><br><br>
Address:<textarea rows="5" cols="20">
My College Name,
My College Address
</textarea>
<br><br>
<input type="checkbox" value="physics">Physics<br>
<input type="checkbox" value="chemistry">Chemistry<br>
<input type="checkbox" value="mathematics">Mathematics<br><br>
Gender:<br>
<input type="radio" value="male" name="gender">Male<br>
<input type="radio" value="female" name="gender">Female<br><br>
<select>
<option value="PU-I">PU-I</option>
<option value="PU-II">PU-II</option>
</select><br><br>
<button type="submit">Submit</button>
<button type="reset">Reset</button>
</form>
<html>
<body>
<table border="2">
<tr>
<th>monday</th>
<th>tuesday</th>
<th>wednesday</th>
<th>thursday</th>
<th>friday</th>
<th>saturday</th>
</tr>

<tr>
<td>physics</td>
<td>chemistry</td>
<td>mathenatics</td>
<td>biology</td>
<td>kannada</td>
<td>sanskrit</td>
</tr>

<tr>
<td>english</td>
<td>hindi</td>
<td>computer science</td>
<td>mathematics</td>
<td>chemistry</td>
<td>physics</td>
</tr>

<tr>
<td>sanskrit</td>
<td>kannada</td>
<td>biology</td>
<td>physics</td>
<td>chemistry</td>
<td>mathematics</td>
</tr>

<tr>
<td>kannada</td>
<td>physics</td>
<td>mahthematics</td>
<td>biology</td>
<td>chemistry</td>
<td>mathematics</td>
</tr>

</table>
</body>
Download this program



2nd puc computer science c++ programs,2nd puc computer science lab programs,2nd puc computer science manual,ii puc computer science lab manual
2ND PUC COMPUTER SCIENCE LAB PROGRAMS 2ND PUC COMPUTER SCIENCE LAB PROGRAMS Reviewed by Vision Academy on December 16, 2019 Rating: 5

No comments:

CheckOut

Powered by Blogger.