Date post: | 27-Feb-2018 |
Category: |
Documents |
Upload: | salmamubarakj |
View: | 264 times |
Download: | 2 times |
of 48
7/25/2019 Computer Science Manual for 2nd PUC, Karnataka board
1/48
SECOND PU
Salma Begum J
Lecturer,
OASIS PU COLLEGE
COMPUTER SCIENCE
OASIS PU COLLEGE
7/25/2019 Computer Science Manual for 2nd PUC, Karnataka board
2/48
1. Write a program to find the frequency of presence of an element in an array.
#include#includevoid main(){int a[100],ele,n,i,freq;clrscr();cout
7/25/2019 Computer Science Manual for 2nd PUC, Karnataka board
3/48
2. Write a program to insert an element into an array at a given position.
#include#includevoid main(){int a[100],ele,n,i,pos;clrscr();cout
7/25/2019 Computer Science Manual for 2nd PUC, Karnataka board
4/48
OUTPUT
7/25/2019 Computer Science Manual for 2nd PUC, Karnataka board
5/48
3. Write a program to delete an element from an array from a given position
#include#includevoid main(){int a[100],n,i,pos;clrscr();cout
7/25/2019 Computer Science Manual for 2nd PUC, Karnataka board
6/48
4. Write a program to sort the elements of an array in ascending order using insertion sort.
#include#includevoid main(){int a[100],n,i,j,temp;clrscr();cout
7/25/2019 Computer Science Manual for 2nd PUC, Karnataka board
7/48
OUTPUT
7/25/2019 Computer Science Manual for 2nd PUC, Karnataka board
8/48
5. Write a program to search for a given element in an array using Binary search method.
#include#includevoid main(){int a[100],ele,n,i,mid,low,high,loc;clrscr();cout
7/25/2019 Computer Science Manual for 2nd PUC, Karnataka board
9/48
OUTPUT
7/25/2019 Computer Science Manual for 2nd PUC, Karnataka board
10/48
6. Write a program to create a class with data members principle, time and rate. Create memberfunctions to accept data values to compute simple interest and to display the result.
#include#includeclass simple_interest{private:int principle,time,rate;float si;public:
void input_data(){coutprinciple;couttime;coutrate;}void compute()
{si=principle*rate*time/100;}void display(){cout
7/25/2019 Computer Science Manual for 2nd PUC, Karnataka board
11/48
7. Write a program to create a class with data members a, b, c and member functions to inputdata, compute the discriminant based on the following conditions and print the roots.
If determinant=0, print the roots that are equal If the discriminant is>0, print the real roots
If the discriminant
7/25/2019 Computer Science Manual for 2nd PUC, Karnataka board
12/48
getch();}
OUTPUT
7/25/2019 Computer Science Manual for 2nd PUC, Karnataka board
13/48
8. Program to find the area of a square/rectangle/triangle using function overloading.
#include#include#includeint a,b,c,l;int area(int a){int area1;
cout
7/25/2019 Computer Science Manual for 2nd PUC, Karnataka board
14/48
case 3:area(a,b,c);break;default:cout
7/25/2019 Computer Science Manual for 2nd PUC, Karnataka board
15/48
9. Program to find the cube of a number using inline functions.
#include#includeint c,n;inline int cube(int a){int c;c=a*a*a;cout
7/25/2019 Computer Science Manual for 2nd PUC, Karnataka board
16/48
10. Write a program to find the sum of the series 1+ x + x2 + + xn using constructors.
#include#include#includeclass series{private:int sum,n,i,x;
public:series(){sum=1;}void input_data(){cout
7/25/2019 Computer Science Manual for 2nd PUC, Karnataka board
17/48
11. Create a base class containing the data members roll number and name. Also create a memberfunction 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#includeclass student{
private:int roll_no;char name[50];public:
void input_data(){coutroll_no;coutname;}void display_data(){
cout
7/25/2019 Computer Science Manual for 2nd PUC, Karnataka board
18/48
m.display_data();m.display_marks();getch();}
OUTPUT
7/25/2019 Computer Science Manual for 2nd PUC, Karnataka board
19/48
12. Create a class containing the following data members register No., name and fees. Also create amember function to read and display the data using the concept of pointers to objects.
#include#includeclass student{private:int roll_no,fees;char name[50];public:
void read_data(){coutroll_no;coutname;coutfees;}void display_data()
{cout
7/25/2019 Computer Science Manual for 2nd PUC, Karnataka board
20/48
13. Write a program to perform push items into the stack.
#include#includeclass stack{private:int top,ele,s[20],i;public:
stack(){top=-1;}void push(){top=top+1;cout
7/25/2019 Computer Science Manual for 2nd PUC, Karnataka board
21/48
OUTPUT
7/25/2019 Computer Science Manual for 2nd PUC, Karnataka board
22/48
14. Write a program to pop elements from the stack.
#include#includeclass stack{private:int top,ele,s[20],i;public:
stack(){top=-1;}void push(){top=top+1;cout
7/25/2019 Computer Science Manual for 2nd PUC, Karnataka board
23/48
case 2:s.pop();break;case 3:s.display();break;default:cout
7/25/2019 Computer Science Manual for 2nd PUC, Karnataka board
24/48
7/25/2019 Computer Science Manual for 2nd PUC, Karnataka board
25/48
15. Write a program to perform enqueue and dequeue.
#include#include#define max 20class queue{private:int front,rear,ele,q[20],i;
public:queue(){front=0;rear=-1;}void enque(){rear=rear+1;cout
7/25/2019 Computer Science Manual for 2nd PUC, Karnataka board
26/48
case 1:q.enque();break;case 2:q.deque();break;case 3:q.display();break;default:cout
7/25/2019 Computer Science Manual for 2nd PUC, Karnataka board
27/48
7/25/2019 Computer Science Manual for 2nd PUC, Karnataka board
28/48
16. Write a program to create a linked list and appending nodes.#include#includeclass linked_list{private:int ele;struct node{
int data;node *link;}*start,*newnode,*temp;public:
linked_list(){start=NULL;}
void append(){coutlink=NULL;
if(start==NULL){start=newnode;cout
7/25/2019 Computer Science Manual for 2nd PUC, Karnataka board
29/48
char choice;int option;linked_list l;clrscr();
do{cout
7/25/2019 Computer Science Manual for 2nd PUC, Karnataka board
30/48
7/25/2019 Computer Science Manual for 2nd PUC, Karnataka board
31/48
Section B SQL
17. Generate the Electricity Bill for one consumer
1.
Create a table
sql> create table ebill(RR_number varchar(10),Consumer_namevarchar(30),bill_date date,Units_consumed number(5));
2.Check the structure of table
sql>desc ebill;
3.
Add records into the table
sql>insert into ebill values(AA451243,Ali,10-jun-2015,650);
sql>insert into ebill values(AA476347,Zuhair,15-jan-2014,50);
sql>insert into ebill values(AA234358,Yasir,28-feb-2015,78);
sql>insert into ebill values(AA765432,Danish,20-mar-2013,245);
sql>insert into ebill values(AA345265,Saif,12-may-2012,65);
sql>insert into ebill values(BA459012,Zaim,24-feb-2012,400);
sql>insert into ebill values(DY567743,Saad,16-jul-2013,35);
7/25/2019 Computer Science Manual for 2nd PUC, Karnataka board
32/48
sql>insert into ebill values(BX876509,Hashim,26-feb-2014,900);
sql>insert into ebill values(DY677569,Eesa,20-jun-2014,897);
sql>insert into ebill values(CA209786,Ryaan,19-jan-2012,979);
4.
View table
sql>select * from ebill;
5.
Add new fields.
sql>alter table ebill add(Due_date date,Bill_amount number(5,2));
6.
Compute bill date and bill amount (if bill amount>100 then first
100 units at Rs.4.5 per unit and rest at Rs.5.5 per unit)sql>update ebill set Due_date=bill_date+15;
sql>update ebill set Bill_amount=100+Units_consumed*4.5 whereunits
7/25/2019 Computer Science Manual for 2nd PUC, Karnataka board
33/48
sql> update ebill set Bill_amount=100+100*4.5+(Units_consumed-100)*5.5 where units>100;
7.
View table
sql>select * from ebill;
7/25/2019 Computer Science Manual for 2nd PUC, Karnataka board
34/48
18. Create a student database and compute the result.
1.
Create table
sql> create table student(student_id number(5),student_namevarchar(20),Subject1 number(4),Subject2 number(4),Subject3number(4),subject4 number(4));
2.Check the structure of tablesql>desc student;
3.
Add records into table
sql>insert into student values(10201,Ali,98,80,78,90);
sql>insert into student values(10202,Zuhair,88,50,38,70);
sql>insert into student values(10203,Yasir,60,50,58,60);
sql>insert into student values(10204,Danish,88,90,98,99);
sql>insert into student values(10205,Saif,30,40,78,90);
sql>insert into student values(10206,Zaim,89,70,95,40);
sql>insert into student values(10207,Saad,67,72,56,40);
sql>insert into student values(10208,Hashim,23,30,40,50);
sql>insert into student values(10209,Eesa,99,90,98,96);
sql>insert into student values(10210,Ryaan,58,70,78,80);
7/25/2019 Computer Science Manual for 2nd PUC, Karnataka board
35/48
4.
View table
sql>select * from student;
5.Add fields to table.sql>alter table student(Total number(5),Percentage number(5),Resultvarchar(15));
6.Calculate total, percentage and result(if all subjects>=35 and
percentage>=60->First class,if all subjects>=35 and
percentage>=35->Second class, If any subjectFail)
sql>update student set Total=Subject1+Subject2+Subject3+Subject4;
sql>update student set Percentage=Total/4;
sql>update student set Result=First Class where Subject1>=35 andSubject2>=35 and Subject3>=35 and Subject4>=35 and Percentage>=60;
sql>update student set Result=Second Class where Subject1>=35 andSubject2>=35 and Subject3>=35 and Subject4>=35 and Percentage>=35;
sql>update student set Result=Fail where Subject1
7/25/2019 Computer Science Manual for 2nd PUC, Karnataka board
36/48
7.
View table
sql>select * from student;
8.
Count the number of students who failed
sql>select count(*) from student where result=Fail;
9.
Count the number of students who have passed.
Sql>select count(*) from student where Result=First Class orResult=Second Class;
7/25/2019 Computer Science Manual for 2nd PUC, Karnataka board
37/48
10.
Count the nmber of students who have scored more than 60
percentage
sql>select count(*) from student where Percentage>60;
11.
List the students who have failed
sql>select * from student where Result=Fail;
12. List the students who have passed.sql>select * from student where Result=First Class orResult=Second Class;
7/25/2019 Computer Science Manual for 2nd PUC, Karnataka board
38/48
19 Generate the Employee details and compute the salary based on the
department.
1.
Create table
sql>create table employee(Emp_id number(5),Emp_namevarchar(30),Department varchar(20),Salary number(10));
2.
Enter 10 rows into table.sql>insert into employee values(786523,Zain,Accounts,30000);
sql>insert into employee values(786521,Zain,Sales,40000);
sql>insert into employee values(786522,Owais,Purchase,35000);
sql>insert into employee values(786523,Saad,Purchase,25000);
sql>insert into employee values(786524,Zuhair,Sales,20000);
sql>insert into employee values(786525,Akhtar,Purchase,36000);
sql>insert into employee values(786526,Ali,Purchase,45000);
sql>insert into employee values(786527,Dyaan,Sales,27000);
sql>insert into employee values(786528,Yasir,Purchase,39000);
sql>insert into employee values(786529,Aamir,Sales,42000);
sql>insert into employee values(786530,Hashim,Sales,36000);
3.
Find the names of the employees who work for sales departmentsql>select * from employee where Department=Sales;
7/25/2019 Computer Science Manual for 2nd PUC, Karnataka board
39/48
4.
Find the number of employees working for purchase department
sql>select count(*) from employee where Department=Purchase;
5.
Find the maximum, minimum and average salary of employees who
work for sales department.
sql>select max(Salary) from employee where Department=Sales;
sql>select min(Salary) from employee where Department=Sales;
sql>select average(Salary) from employee where Department=Sales;
6.View table
sql>select * from employee;
7/25/2019 Computer Science Manual for 2nd PUC, Karnataka board
40/48
7.
Increase the salary of all the employees in purchase department
by 15%.
sql>update employee set Salary=Salary+Salary*0.15 whereDepartment=Purchase;
8.
Add new field Bonus and calculate bonus as 20% of salary.
sql>alter table employee add Bonus number(10);
sql>update employee set Bonus=Salary*0.20;
9.
View updated table.
sql>select * from employee;
10.
Delete the rows for the employee who works for purchase
department.
sql>delete from employee where Department=Purchase;
11.
View table.
sql>select * from employee;
7/25/2019 Computer Science Manual for 2nd PUC, Karnataka board
41/48
7/25/2019 Computer Science Manual for 2nd PUC, Karnataka board
42/48
20. Create database for the bank transaction.
1.
Create table
sql>create table bank(Account number(10),C_name varchar(30),Addressvarchar(20),Initial_amount number(10),T_date date,T_amountnumber(10),T_type varchar(2));
2.
Insert values into the table
sql>insert into bank values(98986745,Ali,Hennur,10000,12-jan-2015,5000,D);
sql>insert into bank values(98986746,Dyaan,Hebbal,30000,18-may-2015,4000,W);
sql>insert into bank values(98986747,Danish,Rajajinagar, 100000,
09-jul-2005,15000,W);
sql>insert into bank values(98986748,Saif,Malleswaram,60000,01-jan-2015,6000,D);
sql>insert into bank values(98986749,Junaid,HSR layout,40000,12-may-2009,9000,D);
sql>insert into bank values(98986750,Zyaan,Maratahalli,30000,10-jun-2015,6500,W);
sql>insert into bank values(98986751,Saad,Kalyan nagar,1000000,21-jan-2011,60000,D);
sql>insert into bank values(98986752,Hamid,Kammanahalli,900000,22-feb-2010,8000,W);
sql>insert into bank values(98986753,Idrees,Benson town,90000,02-mar-2012,10000,W);
sql>insert into bank values(98986754,Aahil,Hennur,400000,10-jan-2014,55000,D);
7/25/2019 Computer Science Manual for 2nd PUC, Karnataka board
43/48
3.
Count and display number of transactions grouping based on type
of transaction.
sql>select T_type,count(*) from bank group by T_type;
4.View table
sql>select * from bank;
5.
Add field balance and calculate balance
sql>alter table bank add Balance number(10);
sql>update bank set Balance=Initial_amount-T_amount where T_type=W;
sql>update bank set Balance=Initial_amount+T_amount where T_type=D;
6.Delete the details of the customers who belong to Hennur.sql>delete from bank where Address=Hennur;
7.
Trace the information of the customer from kamanahalli
sql>select * from bank where Address=Kamanahalli;
7/25/2019 Computer Science Manual for 2nd PUC, Karnataka board
44/48
8.
View Customer id, customer name,Initial amount,type of
transaction,transaction amount,balance.sql>select Account number,C_name,Initial_amount,T_amount,T_type,Balance from bank;
9.Find the sum of amount deposited.sql>select sum(T_amount) from bank where T_type=D;
10. Find the sum of amount withdrawn.
sql>select sum(T_amount) from bank T_type=W;
7/25/2019 Computer Science Manual for 2nd PUC, Karnataka board
45/48
Section C HTML
21. Write a HTML program to create a study time-table.
TableMY STUDY TIME TABLE
DAYMorning study timeCollege timingsEvening study timeQuestion paper solving
MONDAY5:00 to 6:308:30 to 4:006:00 to 8:309:00 to 10:30
TUESDAY5:00 to 6:308:30 to 4:00
6:00 to 8:309:00 to 10:30
WEDNESDAY5:00 to 6:308:30 to 4:006:00 to 7:309:30 to 10:30
THURSDAY5:00 to 6:308:30 to 4:006:00 to 7:309:30 to 10:30
FRIDAY5:00 to 6:308:30 to 4:00
7/25/2019 Computer Science Manual for 2nd PUC, Karnataka board
46/48
6:00 to 7:309:30 to 10:30
SATURDAY5:00 to 6:308:30 to 1:005:00 to 7:30
8:30 to 10:30
All the best!!!
OUTPUT
7/25/2019 Computer Science Manual for 2nd PUC, Karnataka board
47/48
22. Create an HTML program with table and Form.
Table and form
STUDENT'S DATA
Student's Name
Student's ID
father's Name
Mother's Name
Mobile number
7/25/2019 Computer Science Manual for 2nd PUC, Karnataka board
48/48
Email id
OUTPUT