II Puc Practical Final
II Puc Practical Final
II Puc Practical Final
C++ PROGRAMS:
1.WAP to find the frequency of presence of an element in an array.
#include<iostream.h>
#include<conio.h>
main()
{
clrscr();
int a[20], n, i, f=0, s;
cout<<"Enter the number of elements";
cin>>n;
cout<<"Enter the elements";
for(i=0; i<n; i++)
cin>>a[i];
cout<<"Enter the element to find the frequency";
cin>>s;
for(i=0; i<n; i++)
if(s==a[i])
f++;
cout<<"Frequency="<<f;
}
6.WAP to create a class with data members principle, time and rate of interest. Create
member functions to accept data values, to compute simple interest and display the
result.
#include<iostream.h>
#include<conio.h>
class simple
{
private: float p, t, r, si;
public:
void input()
{
cout<<"Enter the principal, time and rate of interest";
cin>>p>>t>>r;
}
void process()
{
si=(p*t*r)/100;
}
void output()
{
cout<<"Simple Interest="<<si;
}
};
main()
{
clrscr();
simple obj;
obj.input();
obj.process();
obj.output();
getch();
}
7.WAP to create a class with data members a,b,c and member functions to input data,
compute the discriminant based on following conditions and print roots.
i) If discriminant=0, print roots are equal and their roots value.
ii) If discriminant>0, print the real roots and their values.
iii) If discriminant<0, print the roots are imaginary and exit the program.
#include<iostream.h>
#include<conio.h>
#include<math.h>
#include<process.h>
class quadratic
{
private: double a, b, c, d, r1, r2;
public: void input();
void process();
void output();
};
8.WAP to find area of a square, rectangle and triangle using function overloading.
#include<iostream.h>
#include<conio.h>
#include<math.h>
class shape
{
public:
float area(float a)
{
return a*a;
}
main()
{
clrscr();
in i;
int a;
cout<<"Enter a number";
cin>>a;
cout<<"Cube of a number="<<i.cube(a);
}
11. Create a base class containing data members rollno and name. Also create a member
unction 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 student
{
private: int regno;
char name[30];
public: void input()
{
cout<<"Enter the register no";
cin>>regno;
cout<<"Enter the name";
cin>>name;
}
void output()
{
cout<<"Register Number="<<regno;
cout<<"\n Name="<<name;
}
};
class marks : public student
{
private: int m1,m2,total;
public:
void input1()
{
cout<<"Enter the marks in 2 subjects";
cin>>m1>>m2;
}
void process()
{
total=m1+m2;
}
void output1()
{
cout<<"\n Subject1 marks="<<m1;
cout<<"\n Subject2 marks="<<m2;
cout<<"\n Total="<<total;
}
};
main()
{
marks m;
m.input();
m.input1();
m.process();
m.output();
m.output1();
getch();
}
12.Create a class containing following data members Register no, name and fees. Also
create a member functions to read and display the data using concepts of pointer to
objects.
#include<iostream.h>
#include<conio.h>
class student
{
private: int regno,fees;
char name[30];
public: void input()
{
cout<<"Enter the register no";
cin>>regno;
cout<<"Enter the name";
cin>>name;
cout<<"Enter the fees";
cin>>fees;
}
void output()
{
cout<<"Register Number="<<regno;
cout<<"\n Name="<<name;
cout<<"\n Fees="<<fees;
}
};
main()
{
student obj,*pobj;
pobj=&obj;
pobj->input();
pobj->output();
getch();
}
SQL QUERIES:
1. Create a table for house hold Electricity bill with the following fields.
Fieldname Type
RR_number varchar2(10)
Consumer_name varchar2(25)
Date_billing date
Units number (4)
d) Compute the bill amount for each customer as per the following rules.
Minimum amount Rs.50
First 100 units Rs.4.50/unit
>100 units Rs.5.50/unit
e) Compute the result as “pass” or fail by checking if the student has scored more than 35
marks in each subject.
Ans: alter table student26 add(result varchar2(10));
update student26 set result=’pass’ where sub1>=35 and sub2>=35 and sub3>=35;
l) Count the number of students who have percentage more than 60.
Ans: select count(*) from student26 where per>=60;
HTML:
1. Write an HTML program to prepare a study timetable.
<HTML>
<HEAD>
<TITLE>TIME TABLE</TITLE>
</HEAD>
<BODY TEXT="RED" BGCOLOR="WHITE">
<H1><CENTER>MY STUDY TIME TABLE FOR THE WEEK</CENTER></H1>
<CENTER>
<TABLE BORDER="12" BORDERCOLOR="RED" CELLSPACING="10" CELLPADDING="12">
<TR>
<TH>DAYS</TH>
<TH>SUBJECTS</TH>
<TH>MORNING STUDY TIME</TH>
<TH>EVENING STUDY TIME</TH>
</TR>
<TR>
<TH>MONDAY/TUESDAY</TH>
<TD>ENGLISH/COMP.SCIENCE</TD>
<TD>5:30-6:30AM</TD>
<TD>7:00-8:30PM</TD>
</TR>
<TR>
<TH>WEDNESDAY/THURSDAY</TH>
<TD>KANNADA/PHYSICS</TD>
<TD>5:30-6:30AM</TD>
<TD>7:00-8:30PM</TD>
</TR>
<TR>
<TH>FRIDAY/SATURDAY</TH>
<TD>CHEMISTRY/MATHS</TD>
<TD>5:30-6:30AM</TD>
<TD>7:00-8:30PM</TD>
</TR>
</TABLE>
</CENTER>
</BODY>
</HTML>