Final II Pu - Cs Lab Manual
Final II Pu - Cs Lab Manual
#include<iostream.h>
#include<iomanip.h>
#include<conio.h>
class frequency
{
private:
int n,m[100],ele,freq;
public:
void getdata();
void findfreq();
void display();
};
1
CS LAB MANUAL II PUC
void main()
{
frequency f;
clrscr();
f.getdata();
f.findfreq();
f.display();
getch();
}
OUTPUT
2
CS LAB MANUAL II PUC
#include<iostream.h>
#include<conio.h>
#include<iomanip.h>
#include<process.h>
class insertion
{
private:
int n,m[100],ele,p;
public:
void getdata();
void insert();
void display();
};
3
CS LAB MANUAL II PUC
for(int i=n-1;i>=p;i--)
m[i+1]=m[i];
m[p]=ele;
n++;
cout<<ele<<" is successfully inserted"<<endl;
}
void insertion :: display()
{
cout<<"The array after the insertion is ";
for(int i=0;i<n;i++)
cout<<setw(4)<<m[i];
}
void main()
{
clrscr();
insertion i;
i.getdata();
i.insert();
i.display();
getch();
}
OUTPUT
4
CS LAB MANUAL II PUC
#include<iostream.h>
#include<iomanip.h>
#include<conio.h>
#include<process.h>
class deletion
{
private:
int m[100],n,ele,p;
public:
void getdata();
void remove();
void display();
};
5
CS LAB MANUAL II PUC
void main()
{
deletion d;
clrscr();
d.getdata();
d.remove();
d.display();
getch();
}
OUTPUT
6
CS LAB MANUAL II PUC
#include<iostream.h>
#include<iomanip.h>
#include<conio.h>
class sorting
{
private:
int m[100],n;
public:
void getdata();
void sort();
void display();
};
7
CS LAB MANUAL II PUC
m[j]=m[j-1];
m[j-1]=temp;
}
j--;
}
}
}
void main()
{
sorting s;
clrscr();
s.getdata();
s.sort();
s.display();
getch();
}
OUTPUT
8
CS LAB MANUAL II PUC
#include<iostream.h>
#include<iomanip.h>
#include<conio.h>
class binarysearch
{
private:
int m[100],n,ele,pos,loc;
public:
void getdata();
void search();
void display();
};
void binarysearch :: getdata()
{
cout<<"How many elements";
cin>>n;
cout<<"Enter the elements ";
for(int i=0;i<n;i++)
cin>>m[i];
cout<<"Enter the search elements ";
cin>>ele;
}
void binarysearch :: display()
{
if(loc>=0)
cout<<"Position ="<<loc;
else
cout<<"Search is unsuccessfull ";
}
void binarysearch :: search()
{
int beg,end,mid;
loc=-1;
beg=0;
end=n-1;
while(beg<=end)
{
mid=(beg+end)/2;
9
CS LAB MANUAL II PUC
if(ele == m[mid])
{
loc=mid;
break;
}
else
if(ele < m[mid])
end=mid-1;
else
beg=mid+1;
}
}
void main()
{
binarysearch b;
clrscr();
b.getdata();
b.search();
b.display();
getch();
}
OUTPUT
10
CS LAB MANUAL II PUC
#include<iostream.h>
#include<iomanip.h>
#include<conio.h>
class interest
{
private:
double p,t,r,si;
public:
void getdata();
void compute();
void putdata();
};
void main()
{
interest i;
clrscr();
i.getdata();
i.compute();
i.putdata();
getch();
}
11
CS LAB MANUAL II PUC
OUTPUT
12
CS LAB MANUAL II PUC
#include<iostream.h>
#include<iomanip.h>
#include<conio.h>
#include<math.h>
#include<process.h>
class quadratic
{
private:
double a,b,c,r1,r2;
public:
void getdata();
void roots();
void putdata();
};
void quadratic :: getdata()
{
cout<<"Enter the co-efficients "<<endl;
cin>>a>>b>>c;
}
void quadratic :: roots()
{
double d=b*b-4*a*c;
if(d==0)
{
cout<<"Roots are equal "<<endl;
r1=-b/(2*a);
r2=r1;
}
else
{
if(d>0)
{
cout<<"Roots are positive and different ";
r1=(-b+sqrt(d))/(2*a);
r2=(-b-sqrt(d))/(2*a);
}
13
CS LAB MANUAL II PUC
else
{
cout<<"Roots are imaginary"<<endl;
}
}
}
void main()
{
quadratic q;
clrscr();
q.getdata();
q.roots();
q.putdata();
getch();
}
OUTPUT
14
CS LAB MANUAL II PUC
#include<iostream.h>
#include<iomanip.h>
#include<conio.h>
#include<math.h>
class funoverload
{
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;
return(sqrt(s*(s-a)*(s-b)*(s-c)));
}
};
void main()
{
clrscr();
double x,y,z;
int ans;
funoverload f1;
cout<<"Enter the choice "<<endl;
cin>>ans;
if(ans==1)
{
cout<<"Enter the sides ";
cin>>x;
cout<<"area of the square ="<<f1.area(x)<<endl;
}
15
CS LAB MANUAL II PUC
else
{
if(ans==2)
{
cout<<"Enter two sides "<<endl;
cin>>x>>y;
cout<<"Area of the rectangle ="<<f1.area(x,y)<<endl;
}
else
if(ans == 3)
{
cout<<"Enter three sides ";
cin>>x>>y>>z;
cout<<setprecision(8);
cout<<"Area of a triangle = "<<f1.area(x,y,z)<<endl;
}
else
cout<<"invalid input";
}
getch();
}
OUTPUT
16
CS LAB MANUAL II PUC
#include<iostream.h>
#include<iomanip.h>
#include<conio.h>
class findcube
{
public:
inline int cube(int x)
{
return(x*x*x);
}
};
void main()
{
findcube f;
int n;
clrscr();
cout<<"Enter the number"<<endl;
cin>>n;
cout<<"CUBE of "<<n<<"="<<f.cube(n);
getch();
}
OUTPUT
17
CS LAB MANUAL II PUC
/* 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 series
{
private:
int sum, x, n;
public:
series(int y, int m)
{
sum=1;
x=y;
n=m;
}
int sumseries();
};
int series::sumseries()
{
for(int i=1; i<=n;i++)
sum=sum+pow(x,i);
return sum;
}
void main()
{
int x, n;
clrscr();
cout<<”Enter the value for Base(X)=”<<endl;
cin>>x;
cout<<”Enter the value for Power(n)”<<endl;
cin>>n;
series s1(x,n);
series s2=s1;
18
CS LAB MANUAL II PUC
OUTPUT
19
CS LAB MANUAL II PUC
#include<iostream.h>
#include<iomanip.h>
#include<conio.h>
class student
{
private:
int rollno;
char name[20];
public:
void read()
{
cout<<"Enter the name ";
cin.getline(name,20);
cout<<"Enter The Roll No";
cin>>rollno;
}
void display()
{
cout<<"Roll no"<<rollno<<endl;
cout<<"Name "<<name<<endl;
}
};
20
CS LAB MANUAL II PUC
void display1()
{
cout<<"Subject 1 ="<<m1<<endl;
cout<<"Subject 2 ="<<m2<<endl;
cout<<" Total marks ="<<total<<endl;
}
};
void main()
{
marks obj;
clrscr();
obj.read();
obj.read1();
obj.display();
obj.display1();
getch();
}
OUTPUT
21
CS LAB MANUAL II PUC
#include<iostream.h>
#include<iomanip.h>
#include<conio.h>
class student
{
private:
int regno;
char name[20];
float fees;
public:
void readdata();
void display();
};
22
CS LAB MANUAL II PUC
void main()
{
student *S;
clrscr();
S->readdata();
S->display();
getch();
}
OUTPUT
23
CS LAB MANUAL II PUC
SQL PROGRAM – 1
Q: create database and use it
Ans: create database electricity;
use electricity;
24
CS LAB MANUAL II PUC
Q: compute the bill amount for each consumer as per the following
rules:
1. min_amt Rs.50
2. first 100 units Rs.4.50 per unit
3. >100 units Rs. 5.50 per unit
Ans:
1. update ebill set billamt=50;
2. update ebill set billamt=billamt+units*4.50 where units<=100;
3. update ebill set billamt=billamt+100*4.50+(units-100)*5.50
where units>100;
25
CS LAB MANUAL II PUC
SQL PROGRAM – 2
26
CS LAB MANUAL II PUC
Q6: To compute result as “PASS” or “FAIL” by checking if the student has scored
more than 35 marks in each subject.
Ans:
update student set result=’pass’ where(sub1>=35 and sub2>=35 and
sub3>=35 and sub4>=35 and sub5>=35 and sub6>=35);
Q8: Retrieve only student id and student name of all the students.
Ans. select sid, name from student;
<HTML>
<HEAD>
<TITLE> CLASS TIME TABLE </TITLE>
</HEAD>
<BODY>
<CENTER> <H3> PU SCIENCE COLLEGE </H3>
<CENTER> <H4> TIME TABLE 2024-25 </H4>
<TABLE BORDER=10 BORDERCOLOR=RED BGCOLOR=CORNSILK
CELLSPACING=2
CELLPADDING=15>
<CAPTION> <B> II PUC PCMCs </B> </CAPTION>
<TR BGCOLOR=PEACHPUFF>
<TD ROWSPAN=2 ALIGN=CENTER> <B> DAY </B> </TD>
<TD COLSPAN=8 ALIGN=CENTER> <B> TIMINGS </B></TD>
</TR>
<TR BGCOLOR=RED>
<TH> 9.20 - 10.20 </TH>
<TH> 10.20 - 11.20 </TH>
<TH> 11.20 - 11.30 </TH>
<TH> 11.30 - 12.30 </TH>
<TH> 12.30 - 1.30 </TH>
<TH> 1.30 - 2.30 </TH>
<TH> 2.30 - 3.15 </TH>
<TH> 3.15 - 4.00 </TH>
</TR>
<TR>
<TD> MONDAY </TD>
<TD> MATHS </TD>
<TD> PHYSICS </TD>
<TD ROWSPAN=6 ALIGN=”CENTER”>SHORT BREAK</TD>
<TD> CHEMISTRY </TD>
<TD> COMP SCI </TD>
<TD ROWSPAN=6 ALIGN=CENTER>LUNCH BREAK</TD>
<TD COLSPAN=2ALIGN=CENTER><………COMP SCI LAB…..> </TD>
28
CS LAB MANUAL II PUC
</TR>
<TR>
<TD>TUESDAY</TD>
<TD> PHYSICS </TD>
<TD> MATHS </TD>
<TD> CHEMISTRY </TD>
<TD> ENGLISH </TD>
<TD COLSPAN=2 ALIGN=CENTER><………PHYSICS LAB……></TD>
</TR>
<TR>
<TD> WEDNESDAY </TD>
<TD> COMP SCI </TD>
<TD> PHYSICS </TD>
<TD> MATHS </TD>
<TD> KANNADA </TD>
<TD COLSPAN=2 ALIGN=CENTER><……CHEMISTRY LAB….></TD>
</TR>
</TABLE>
</CENTER>
</BODY>
</HTML> OUTPUT
29
CS LAB MANUAL II PUC
<HTML>
<HEAD>
<TITLE> ONLINE APPLICATION </TITLE>
</HEAD>
<BODY>
<FORM>
<H3 ALIGN=CENTER> FIRST PUC APPLICATION FORM </H3>
<TABLE BORDER= 5 CELLSPACING=5 CELLPADDING=5%
ALIGN=CENTER>
<TR>
<TD ALIGN=LEFT>STUDENT NAME: </TD>
<TD><INPUT TYPE=”TEXT” NAME=”STUNAME”></TD>
</TR>
<TR>
<TD ALIGN=LEFT>GENDER: </TD>
<TD><INPUT TYPE=RADIO NAME=GEN VALUE=”M”>MALE
<INPUT TYPE=RADIO NAME=GEN VALUE=”F”>FEMALE</TD>
</TR>
<TR>
</TD>
</TR><TR>
<TD><INPUT TYPE="SUBMIT" VALUE="SUBMIT THE FORM"> </TD>
<TD><INPUT TYPE="RESET" VALUE="RESET THE FORM"></TD>
</TR>
</TABLE>
</FORM>
</BODY>
</HTML>
OUTPUT
31