You are on page 1of 49

Lab 1: program /* frequency */

#include<iostream.h>
#include<conio.h>
#include<iomanip.h>
class flag
{
int n, i, a[10], ele, freq;
public:
void read();
void find();
void display();
};

void flag :: read()


{
cout<<"Enter the size ";
cin>>n;
cout<<endl<<"Enter the element ";
for(i=0; i<n; i++)
cin>>a[i];
cout<<"Enter the search element ";
cin>>ele;
}
void flag :: find()
{
freq=0;
for(i=0; i<n; i++)
if(a[i] == ele)
freq++;
}
void flag :: display()
{
if(freq >= 0)
cout<<"Frequency of "<<ele<<" is "<<freq<<” times”;
else
cout<<ele<<" does not exist ";
}

void main()
{
flag F;
clrscr();
F.read();
F.find();
F.display();
getch();

}
OUTPUT 1
Enter the the size 5
Enter the element 12 1 3 25 34 25
Enter the search element 25
Frequency of 25 is 2 times

OUTPUT 2
Enter the the size 5
Enter the element 12 1 3 25 34 25
Enter the search element 36
36 does not exist

======end======
Lab 2: program /* insert an element into an array */
#include<iostream.h>
#include<process.h>
#include<iomanip.h>
#include<conio.h>
class flag
{
int n, i, a[10], ele, p;
public:
void read();
void find();
void display();
};

void flag :: read()


{
cout<<"Enter the size ";
cin>>n;
cout<<endl<<"Enter the element ";
for(i=0; i<n; i++)
cin>>a[i];
cout<<"Enter the element to be inserted ";
cin>>ele;
cout<<"Enter the position ";
cin>>p;
}
void flag :: find()
{
if(p>n)
{
cout<<endl<<" Invalid Position ";
exit(0);
}
else
{
for(i=n-1; i>=p; i--)
a[i+1] =a[i];
a[p]=ele;
n++;
cout<<endl<<ele<<" is successful inserted "<<endl;
}

}
void flag :: display()
{
cout<<endl<<"The array is "<<endl;
for(i=0; i<n; i++)
cout<<setw(4)<<a[i];
}
void main()
{
clrscr();
flag F;
F.read();
F.find();
F.display();
getch();

OUTPUT 1
Enter the size 5
Enter the element 12 13 14 15 16
Enter the element to be inserted 11
Enter the position 0
11 is successful inserted
The array is
11 12 13 14 15 16

OUTPUT 2
Enter the size 5
Enter the element 12 13 14 15 16
Enter the element to be inserted 11
Enter the position 8
Invalid position

=====end======
Lab 3: program /* delete an element from an array */

#include<iostream.h>
#include<process.h>
#include<iomanip.h>
#include<conio.h>
class flag
{
int n, i, a[10], ele, p;
public:
void read();
void find();
void display();
};

void flag :: read()


{
cout<<"Enter the size ";
cin>>n;
cout<<endl<<"Enter the element ";
for(i=0; i<n; i++)
cin>>a[i];
cout<<"Enter the postion ";
cin>>p;
}
void flag :: find()
{
if(p>n-1)
{
cout<<endl<<" Invalid Position ";
exit(0);
}
else
{
ele=a[p];
for(i=p; i<n; i++)
a[i] =a[i+1];
n--;
cout<<endl<<ele<<" is sucessfully removed "<<endl;
}

}
void flag :: display()
{
cout<<endl<<"The array is "<<endl;
for(i=0; i<n; i++)
cout<<setw(4)<<a[i];
}
void main()
{
clrscr();
flag F;
F.read();
F.find();
F.display();
getch();

OUTPUT 1
Enter the size 5
Enter the element 12 13 14 15 16
Enter the position 1
13 is successful removed
The array is
12 14 15 16

OUTPUT 2
Enter the size 5
Enter the element 12 13 14 15 16
Enter the position 10
Invalid position

======end======
Lab 4: program /* insertion sort of an array element*/
#include<iostream.h>
#include<iomanip.h>
#include<conio.h>
class flag
{
int n, i, a[10];
public:
void read();
void find();
void display();
};

void flag :: read()


{
cout<<"Enter the size ";
cin>>n;
cout<<endl<<"Enter the element ";
for(i=0; i<n; i++)
cin>>a[i];
}
void flag :: find()
{
int temp, j;
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--;
}
}
}
void flag :: display()
{
cout<<endl<<"The array is "<<endl;
for(i=0; i<n; i++)
cout<<setw(4)<<a[i];
}

void main()
{
clrscr();
flag F;
F.read();
F.find();
F.display();
getch();

}
OUTPUT 1
Enter the size 5
Enter the element 18 17 16 15 14
The array is
14 15 16 17 18

OUTPUT 2
Enter the size 5
Enter the element 25 1 14 5 34
The array is
1 5 14 25 34

======end======
Lab 5: program /* binary search */
#include<iostream.h>
#include<iomanip.h>
#include<conio.h>
class flag
{
int n, i, a[10], ele, loc;
public:
void read();
void find();
void display();
};

void flag :: read()


{
cout<<"Enter the size ";
cin>>n;
cout<<endl<<"Enter the element ";
for(i=0; i<n; i++)
cin>>a[i];
cout<<endl<<"Enter the search element ";
cin>>ele;
}
void flag :: find()
{
int beg, end, mid;
loc = -1;
beg = 0;
end = n-1;
while(beg<=end)
{
mid=(beg+end)/2;
if(ele == a[mid])
{
loc = mid;
break;
}
else
if(ele < a[mid])
end = mid - 1;
else
beg = mid + 1;
}
}
void flag :: display()
{ if(loc >= 0)
cout<<endl<<ele<<" is found at "<<loc<<" position in an array ";
else
cout<<endl<<ele<<" is not found ";
}
void main()
{
clrscr();
flag F;
F.read();
F.find();
F.display();
getch();

OUTPUT 1
Enter the size 5
Enter the element 18 17 16 15 14
Enter the search element 17
17 is found at 2 position in an array

OUTPUT 2
Enter the size 5
Enter the element 18 17 16 15 14
Enter the search element 23
23 is not found

======end======
Lab 6: program /* simple interest */

#include<iostream.h>
#include<iomanip.h>
#include<conio.h>
class flag
{
float p,t,r,s;
public:
void read();
void find();
void display();
};

void flag :: read()


{
cout<<"Enter Principal amount , Rate of interest ,and Time ";
cin>>p>>t>>r;
}
void flag :: find()
{
s=(p*t*r)/100;
}
void flag :: display()
{
cout<<endl<<" Simple Interest is "<<s;
}

void main()
{
clrscr();
flag F;
F.read();
F.find();
F.display();
getch();

OUTPUT 1
Enter Principal amount , Rate of interest ,and Time 1000 2 1.5
Simple Interest is 30.00

OUTPUT 2
Enter Principal amount , Rate of interest ,and Time 180000 5 7.5
Simple Interest is 67500.00

======end======
Lab 7: program /* determinants */
#include<iostream.h>
#include<iomanip.h>
#include<process.h>
#include<math.h>
#include<conio.h>
class flag
{
float a,b,c,r1,r2,d;
public:
void read();
void find();
void display();
};

void flag :: read()


{
cout<<"Enter co-efficient ";
cin>>a>>b>>c;
}
void flag :: find()
{
d=(b*b)-(4*a*c);
if(d==0)
{
cout<<endl<<" Roots are equal ";
r1=(-b-sqrt(d))/(2*a);
r2=r1;
}
else
if(d>0)
{
cout<<endl<<" Roots are different";
r1=(-b+sqrt(d))/(2*a);
r2=(-b-sqrt(d))/(2*a);
}
else
{
cout<<endl<<" Roots are imaginary";
exit(0);
}
}
void flag :: display()
{
cout<<endl<<" First Root "<<r1;
cout<<endl<<" Second Root "<<r2;
}
void main()
{
clrscr();
flag F;
F.read();
F.find();
F.display();
getch();
}

OUTPUT 1
Enter the co-efficient 2 4 2
Roots are equal
First root = -1
Second root = -1

OUTPUT 2
Enter the co-efficient 1 3 -4
Roots are different
First root = -1
Second root = -4

OUTPUT 3
Enter the co-efficient 3 2 5
Roots are imaginary
======end======
Lab 8: program /* function overloading */
#include<iostream.h>
#include<iomanip.h>
#include<math.h>
#include<conio.h>
class flag
{
float s;
public:
float area(float a)
{ return a*a; }
float area(float a, float b)
{ return a*b; }
float area(float a, float b, float c)
{ s=(a+b+c)/2;
return(sqrt(s*(s-a)*(s-b)*(s-c)));
}
};

void main()
{
float x,y,z;
int ch;
flag F;
clrscr();
cout<<endl<<" 1. Area of a Square 2. Area of Rectangle 3. Area of Triangle ";
cout<<endl<<" Enter you choice ";
cin>>ch;
if(ch==1)
{
cout<<endl<<"Enter one side ";
cin>>x;
cout<<endl<<"Area of a Square is "<<F.area(x);
}
else
if(ch==2)
{
cout<<endl<<"Enter two sides ";
cin>>x>>y;
cout<<endl<<"Area of a Rectangle is "<<F.area(x,y);
}
else
if(ch==3)
{
cout<<endl<<"Enter Three sides ";
cin>>x>>y>>z;
cout<<endl<<"Area of a Triangle is "<<F.area(x,y,z);
}
else
cout<<endl<<"Invalid Input";
getch();
}
OUTPUT 1
1. Area of a Square 2. Area of Rectangle 3. Area of Triangle
Enter you choice 1
Enter one side 2.5
Area of a Square is 6.25

OUTPUT 2
1. Area of a Square 2. Area of Rectangle 3. Area of Triangle
Enter you choice 2
Enter two sides 5.25 3.75
Area of a Rectangle is 19.6875

OUTPUT 3
1. Area of a Square 2. Area of Rectangle 3. Area of Triangle
Enter you choice 3
Enter Three sides 5.0 3.0 5.0
Area of a Triangle is 7.1555

OUTPUT 4
1. Area of a Square 2. Area of Rectangle 3. Area of Triangle
Enter you choice 4
Invalid Input

======end======
Lab 9: program /* inline function */
#include<iostream.h>
#include<conio.h>
#include<iomanip.h>
class flag
{
public:
inline int cube( int n)
{
return (n*n*n);
}
};
void main()
{
int n;
flag F;
clrscr();
cout<<endl<<" Enter a number ";
cin>>n;
cout<<endl<<" Cube of "<<n<< " is "<<F.cube(n);
getch();
}

OUTPUT 1
Enter a number 5
Cube of 5 is 125

OUTPUT 2
Enter a number 3
Cube of 5 is 27

======end======
Lab 10: program /* Sum of the series */
#include<iostream.h>
#include<conio.h>
#include<iomanip.h>
#include<math.h>
class flag
{
int i, x, sum, n;
public:

flag ( )
{
sum =1 ;
}
void read()
{
cout<<endl<<:Enter the values for X and N “;
cin>>x>>n;
}

void find()
{
for ( i=1 ; i<n ; i++)
Sum = sum + pow(x,i)
}
void display()
{
cout<<” sum of series = “<<sum;
}

};
void main()
{
flag F;
clrscr();
F.read();
F.find():
F.display();
getch();

OUTPUT 1
Enter the values for X and N 2 3
Sum of series = 15

OUTPUT 2
Enter the values for X and N 3 3
Sum of series = 45

======end======
Lab 11: program /* inheritance */
#include<iostream.h>
#include<conio.h>
#include<iomanip.h>
class flag
{
int roll;
char name[40];
public:

void read()
{
cout<<"Enter the Student name ";
cin.getline(name,30);
cout<<endl<<"Enter the Student Register Number ";
cin>>roll;
}
void display()
{
cout<<endl<<" Student Register Number "<<roll;
cout<<endl<<" Student Name "<<name;
}
};
class sample : public flag
{
int m1,m2, total;
public:

void read2()
{
cout<<"Enter 2 subject marks ";
cin>>m1>>m2;
total=m1+m2;
}
void display2()
{
cout<<endl<<" Subject1 "<<m1;
cout<<endl<<" Subject2 "<<m2;
cout<<endl<<" Total "<<total;
}
};

void main()
{
clrscr();
sample F;
F.read();
F.read2();
F.display();
F.display2();
getch();

}
OUTPUT 1
Enter the Student name Ravi
Enter the Student Register Number 23434
Enter 2 subject marks 56 67

Student Register Number 23434


Student Name Ravi
Subject1 56
Subject2 67
Total 123

OUTPUT 2
Enter the Student name Kiran
Enter the Student Register Number 98988
Enter 2 subject marks 45 55

Student Register Number 98988


Student Name Kiran
Subject1 45
Subject2 55
Total 100

======end======
Lab 12: program /* pointers */
#include<iostream.h>
#include<conio.h>
#include<iomanip.h>
class flag
{
float r,h,v;
public:
void read();
void display();
};

void flag :: read()


{
cout<<"Enter the Student name ";
cin.getline(name,30);
cout<<endl<<"Enter the Student Register Number ";
cin>>roll;
cout<<"Enter the Student Fees ";
cin>>fee;
}
void flag :: display()
{
cout<<endl<<" Student Register Number "<<roll;
cout<<endl<<" Student Name "<<name;
cout<<endl<<" Student Fee "<<fee;
}
void main()
{
clrscr();
flag *F, S;
F=&S;
F -> read();
F -> display();
getch();
}
OUTPUT 1
Enter the Student name Ravi
Enter the Student Register Number 23232
Enter the Student Fees 120000

Student Register Number 23232


Student Name Ravi
Student Fee 120000

OUTPUT 2
Enter the Student name Kiran
Enter the Student Register Number 7676
Enter the Student Fees 180000

Student Register Number 7676


Student Name Kiran
Student Fee 180000
======end======
Lab 13: program /* stack */

#include<iostream.h>
#include<iomanip.h>
#include<conio.h>
#include<ctype.h>
#define MAX 4
class flag
{ int a[MAX];
int i, top;
public:
flag()
{ top = -1; }
void push(int ele)
{ if(top == MAX-1)
{
cout<<endl<<"Stack is full ";
return;
}
top++;
a[top]=ele;
cout<<endl<<ele<<" is pushed";
}
void display()
{ if(top != -1)
{
cout<<endl<<" Stack Contains ";
for( i=0; i<=top; i++)
cout<<setw(4)<<a[i];
}
else
cout<<endl<<" Stack is empty";
}
};
void main()
{
flag F;
char ch;
int ele;
clrscr();
F.display();
cout<<endl<<" Do you want to push an element (Y/n)? ";
cin>>ch;
while(toupper(ch) == 'Y')
{
cout<<endl<<" Enter a number ";
cin>>ele;
F.push(ele);
F.display();
cout<<endl<<" Do you want to push another element into stack (Y/N)? ";
cin>>ch;
}
getch();
}

OUTPUT
Stack is empty
Do you want to push an item (Y/N)?Y
Enter a number 12
12 is pushed
Stack contains
12
Do you want to push another element into stack (Y/N)?Y
Enter a number 15
15 is pushed
Stack contains
12 15
Do you want to push another element into stack (Y/N)?Y
Enter a number 25
25 is pushed
Stack contains
12 15 25
Do you want to push another element into stack (Y/N)?Y
Enter a number 40
40 is pushed
Stack contains
12 15 25 40
Do you want to push another element into stack (Y/N)?Y
Stack is full
======end======
Lab 14: program /* push */

#include<iostream.h>
#include<iomanip.h>
#include<conio.h>
#define MAX 4

class flag
{
int a[MAX];
int top;
public:
flag()
{
top = -1;
}
void push(int ele)
{
if(top == MAX-1)
{
cout<<endl<<"Stack is full ";
return;
}
top++;
a[top]=ele;
cout<<endl<<ele<<" is pushed ";
}
void display()
{
if(top != -1)
{
cout<<endl<<" Stack Contains ";
for(int i=0; i<=top; i++)
cout<<setw(4)<<a[i];
}
else
cout<<endl<<" Stack is empty";
}
void pop()
{
if(top == -1)
{
cout<<endl<<"Stack is empty ";
return;
}
else
{
int data = a[top];
top - -;
cout<<endl<<data<<" is popped";
}
}
};
void main()
{ flag F;
clrscr();
F.display();
cout<<endl<<” Result of push operations “<<endl;
F.push(10); F.display();
F.push(20); F.display();
F.push(30); F.display();
F.push(40); F.display();
cout<<endl<<” Result of pop operations “<<endl;
F.pop(); F.display();
F.pop(); F.display();
F.pop(); F.display();
F.pop(); F.display();
getch();
}

OUTPUT
Result of push operations
Stack is empty
Do you want to push an item (Y/N)?Y
10 is pushed
Stack contains
10
20 is pushed
Stack contains
10 20
30 is pushed
Stack contains
10 20 30
40 is pushed
Stack contains
10 20 30 40
Stack is full
Result of pop operations
40 is popped
Stack contains
10 20 30
30 is popped
Stack contains
10 20
20 is popped
Stack contains
10
10 is popped
Stack is empty
======end======
Lab 15: program /* queue */

#include<iostream.h>
#include<iomanip.h>
#include<conio.h>
#define MAX 4

class flag
{
int q[MAX];
int first,last;
int count;
public:
flag();
void enqueue(int x);
int dequeue();
void display();
};
flag :: flag()
{
first = 0;
last = MAX-1;
count = 0;
}
void flag :: enqueue(int x)
{
last = (last+1) % MAX;
q[last] = x;
cout<<endl<<x<<" is inserted ";
count++;
}
int flag :: dequeue()
{
int x = q[first];
first=(first+1) % MAX;
count--;
cout<<endl<<x<<" is deleted ";
return x;
}
void flag :: display()
{
if(count > 0)
{
cout<<endl<<" Queue contains ";
for(int i=first; i<=last; i++)
cout<<q[i]<<setw(4);
}
else
cout<<endl<<" Queue is empty";
}
void main()
{
flag F;
clrscr();
F.display();
cout<<endl<<”The enqueue operations “<<endl;
F.enqueue(10); F.display();
F.enqueue(20); F.display();
F.enqueue(30); F.display();
F.enqueue(40); F.display();
cout<<endl<<”The dequeue operations “<<endl;
F.dequeue(); F.display();
F.dequeue(); F.display();
F.dequeue(); F.display();
F.dequeue(); F.display();

getch();
}

OUTPUT
The enqueue operation
10 is inserted
Queue contains
10
20 is inserted
Queue contains
10 20
30 is inserted
Queue contains
10 20 30
40 is inserted
Queue contains
10 20 30 40
The dequeue operations
10 is deleted
Queue contains
20 30 40
20 is deleted
Queue contains
30 40
30 is deleted
Queue contains
40
40 is deleted
Queue is empty

======end======
Lab 16: program /* lined list */

/* linked list*/
#include<iostream.h>
#include<iomanip.h>
#include<conio.h>
class link
{

struct Node
{
int data;
Node *link;
}*START;

public:
link();
void print();
void append(int num);
void count();
};

link::link()
{
START = NULL;
}

void link::print()
{
if (START == NULL)
{
cout<<endl<<"Linked list is empty"<<endl;
return;
}

cout<<"Linked List Contins ";


Node *tmp = START;
while(tmp != NULL)
{
cout<<tmp->data<<" ";
tmp=tmp->link;
}
}
void link::append(int num)
{
Node *p;
p = new Node;
p->data = num;
p-> link = NULL;
if(START == NULL)
{
START = p;
cout<<endl<<num<<" is inserted as the first node"<<endl;
}
else
{
Node *n = START;
while(n->link != NULL)
n = n->link;
n->link = p;
cout<<endl<<num<<" is inserted"<<endl;
}
}
void link:: count()
{
Node *tmp;
int c=0;
for(tmp = START; tmp != NULL; tmp = tmp->link)
c++;
cout<<endl<<"Number of nodes in a linked list is "<<c<<endl;
}
void main()
{
clrscr();
link *obj = new link();
obj->print();
obj->append(20);
obj->print();
obj->count();
obj->append(30);
obj->print();
obj->count();
obj->append(40);
obj->print();
obj->count();
getch();
}

OUTPUT
Linked list empty
20 is inserted as the first node
Linked list contains 20
Number of nodes in the linked list is 1
30 is inserted
Linked list contains 20 30
Number of nodes in the linked list is 2
40 is inserted
Linked list contains 20 30 40
Number of nodes in the linked list is 3
50 is inserted
Linked list contains 20 30 40 50
Number of nodes in the linked list is 3

======end======
SQL -1

1. Create a table for house hold Electricity bill with the following:-

2. Command to INSERT record(tuple) into the table.

3. Command to add two new fields to the table

Amount number(6,2)
Due date
4. Command to compute bill amount

A. Minimum amount RS. 50/-

B. For first 100 units Rs. 4.50/- per unit

C. For more that 100 units Rs. 5.50/- per unit

5. Command to view the bill statement

ANS 1Q:

SQL> create table electricity (rr_num varchar(8), number char(8), billing date, units number(4));

ANS 2Q

SQL> insert into electricity values('A101','Manju','12-Feb-2022',34);

SQL> insert into electricity values('A102','Reeta','14-Mar-2022',144);

SQL> insert into electricity values('A103','Vikas','23-Jun-2022',100);

SQL> insert into electricity values('A203','Nithin','23-Aug-2022',29);

ANS 3Q

SQL> alter table electricity add( amount number(6,2), due date);

ANS 4Q

SQL>update electricity set amount = 50;

SQL> update electricity set amount =amount + 100*4.50+(unit-100)*5.50 where units>100;

SQL> update electricity set amount =amount + 100*4.50 where units<=100;

SQL> update electricity set due = billing +15;


ANS 5Q

SQL> select * from electricity;

take print out and past it in un-rule page


OUTPUT:-
RR_NUM NAME BILLLING UNITS AMOUNT DUE

- - - - - - - - - - - - - -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -- - - - - - - - - --

A101 Manju 12-FEB-22 34 1314.00 27-Feb-22

A102 Reeta 14-MAR-22 144 742.00 29-Mar-22

A103 Vikas 23-JUN-22 100 1380.00 08-JUN-22

A203 Nithin 23-AUG-22 29 1309.00 07-SEP-22

======end======
SQL -2
Create s student data base and compute the result

1. Create a table: -
2. Insert 5 record(tuple) into the table: -
3. Command to alter the table:-
i. Add 3 column such as total, percentage and result
ii. Update the total
iii. Update the percentage
iv. Update the result either pass or fail
4. Command to display the stud table
5. Command to display the only id and name from the stud table
6. Command to list the student who have passed
7. Command to list the student who have failed
8. Count the number of the student who have passed
9. Count the number of the student who have passed
10. Command to list the student who have passed
11. Command to sort the student list according to the student id

ANS 1Q
SQL> create table stud (id number(4), name varchar(20), sub1 number(3), sub2
number(3), sub3 number(3), sub4 number(3), sub5 number(3), sub6 number(3));
ANS 2Q
SQL> insert into stud values (125, 'Anu', 67,89,78,56,45,67);
SQL> insert into stud values (126, 'Kavya', 97,69,68,86,65,97);
SQL> insert into stud values (128, 'Bhuvan', 100,69,86,95,99);
SQL> insert into stud values (127, 'Zain',54,34,76,26,45,69);
SQL> insert into stud values (124, 'Santhosh',99,34,99,99,99,99)
ANS 3Q (i)
SQL> alter table stud add( total number(3), per number(5,2), result char(6)) ;
ANS 3Q(ii)
SQL> update stud set total = sub1 + sub2 +sub3 + sub4 + sub5 + sub6;
ANS 3Q(iii)
SQL> update stud set per = total/6.0;
ANS 3Q(iv)
SQL> update stud set result = 'Pass' where sub1>=35 and sub2>=35 and sub3>=35
and sub4>=35 and sub5>=35 and sub6>=35;

SQL> update stud set result = 'Fail' where sub1<35 or sub2<35 or sub3<35 or sub4<35
or sub5<35 or sub6<35;

ANS 4Q
SQL> select * from stud ;
ANS 5 Q
SQL> select id, name from stud;
ANS 6Q
SQL> select * from stud where result = 'Pass';
ANS 7Q
SQL> select * from stud where result = 'Fail';
ANS 8Q
SQL> select count(*) from stud where result ='Fail';
ANS 9Q
SQL> select count(*) from stud where result ='Fail';
ANS 10Q
SQL>select * from stud where per >=60;
ANS 11Q
SQL> select * from stud order by id;
take print out and past it in un-rule page
OUTPUT ANS 4Q:-
ID NAME SUB1 SUB2 SUB3 SUB4 SUB5 SUB6 TOTAL PER RESULT
-----------------------------------------------------------------------------------------------------------------
125 Anu 67 89 78 56 45 67 402 67.00 Pass
126 Kavya 97 69 68 86 65 97 482 80.33 Pass
128 Bhuvan 100 69 86 86 95 99 535 89.17 Pass
127 Zain 54 34 76 26 45 69 304 50.67 Fail
124 Santhosh 99 34 99 99 99 99 529 88.17 Fail
OUTPUT ANS 5Q:-
ID NAME
-----------------------------
125 Anu
126 Kavya
128 Bhuvan
127 Zain
124 Santhosh

OUTPUT ANS 6Q:-


ID NAME SUB1 SUB2 SUB3 SUB4 SUB5 SUB6 TOTAL PER RESULT
-----------------------------------------------------------------------------------------------------------------
125 Anu 67 89 78 56 45 67 402 67.00 Pass
126 Kavya 97 69 68 86 65 97 482 80.33 Pass
128 Bhuvan 100 69 86 86 95 99 535 89.17 Pass
OUTPUT ANS 7Q:-
ID NAME SUB1 SUB2 SUB3 SUB4 SUB5 SUB6 TOTAL PER RESULT
-----------------------------------------------------------------------------------------------------------------
127 Zain 54 34 76 26 45 69 304 50.67 Fail
124 Santhosh 99 34 99 99 99 99 529 88.17 Fail
OUTPUT ANS 8Q:-
count(*)
-------------------
2
OUTPUT ANS 9Q:-
count(*)
-------------------
3
OUTPUT ANS 10Q:-
ID NAME SUB1 SUB2 SUB3 SUB4 SUB5 SUB6 TOTAL PER RESULT
-----------------------------------------------------------------------------------------------------------------
125 Anu 67 89 78 56 45 67 402 67.00 Pass
126 Kavya 97 69 68 86 65 97 482 80.33 Pass
128 Bhuvan 100 69 86 86 95 99 535 89.17 Pass
124 Santhosh 99 34 99 99 99 99 529 88.17 Fail
OUTPUT ANS 11Q:-
ID NAME SUB1 SUB2 SUB3 SUB4 SUB5 SUB6 TOTAL PER RESULT
-----------------------------------------------------------------------------------------------------------------
124 Santhosh 99 34 99 99 99 99 529 88.17 Fail
125 Anu 67 89 78 56 45 67 402 67.00 Pass
126 Kavya 97 69 68 86 65 97 482 80.33 Pass
127 Zain 54 34 76 26 45 69 304 50.67 Fail
128 Bhuvan 100 69 86 86 95 99 535 89.17 Pass
======end======
SQL -3

1. Generate the employee and computer the salary based on the department

2. Add 4 record (tuple) into the employee table

3. Command to list all details of employee

4. Generate the employee and computer the salary based on the department

5. Add 4 record (tuple) into the dept table

6. Command to list all details of dept

7. Command to find the name of all employee who works for the account department.

8. Command to find the number of employee who works for the account department.

9. Command to find minimum, maximum and average salary of the employee who works for the
account department.

10. Command to list the employees working for particular supervisor.

11. Command to retrieve the department name for each department name for each department
where only two works.

12. Command to increase the salary of all employee in the sales department by 15%.

13. Command to add a new column to the table employee called bonus and compute 5% of the
salary to the said field.

i. Command to list employee who dept_id =3;

14. Command to delete all the row for employee in the apprentice department.

i. Command to list employee;

ANS 1Q

SQL> create table employee ( emp_id number(4), dept_id number(4), name varchar(20),
salary number(8));

ANS 2Q

SQL> insert into employee values (1009, 01,'Arun', 25000);

SQL> insert into employee values (1026, 02,'Priya', 35000);

SQL> insert into employee values (1238, 03,'Surya', 45000);

SQL> insert into employee values (1555, 04,'Keerthi', 15000);

ANS 3Q

SQL> select * from employee;


ANS 4Q

SQL> create table dept ( dept_id number(4), name varchar(20), supervisor char(12));

ANS 5Q

SQL> insert into dept values (01, 'Purchase', 'ammen');

SQL> insert into dept values (02, 'Account', 'Reddy' );

SQL> insert into dept values (03,'Sales', 'Mehra' );

SQL> insert into dept values (04, 'Apprentice' , 'Ashish' );

ANS 6Q

SQL> select * from dep;

ANS 7Q

SQL> select * from employee where dept_id = ( select dept_id from dept where name='Account');

ANS 8Q

SQL> select count( *) from employee where dept_id = ( select dept_id from dept where
name='Account');

ANS 9Q

SQL> select min(salary) from employee where dept_id = ( select dept_id from dept where
name='Account');

SQL> select max(salary) from employee where dept_id = ( select dept_id from dept where
name='Account');

SQL> select avg(salary) from employee where dept_id = ( select dept_id from dept where
name='Account');

ANS 10Q

SQL> select * from employee where dept_id = ( select dept_id from dept where
SUPERVISOR='Mehra'');

ANS 11Q

SQL> select name from dept where dept_id = ( select dept_id from employee group by dept-id
having count(*)=2');

ANS 12Q

SQL> update employee set salary = salary + salary * 0.15 where dept_id = ( select dept_id from
dept where name='Sales');

1 row updated.
ANS 12 Q i)

SQL> select * from emp;

ANS 13Q

SQL> alter table employee add bonus number(8);

SQL> select * from employee;

ANS 14Q

SQL> delete from employee where dept_id = (select dept_id from where name = 'Apprentice');

1 row deleted.

SQL> select * from emp;

NOTE
take print out and past it in un-rule page
OUTPUT ANS 3Q :-
EMP-ID DEPT_ID NAME SALARY

-------------- --------------- ------------- ------------------

1009 1 Arun 25000

1026 2 Priya 35000

1238 3 Surya 45000

1555 4 keerthi 15000

6731 2 Rahul 25400

OUTPUT ANS 6Q:-


DETP_ID NAME SUPERVISOR

------------------ -------------- -------------------

1 Purchase Ameen

2 Account Reddy

3 Sales Mehra

4 Apprentice Ashish
OUTPUT ANS 7Q:-
EMP-ID DEPT_ID NAME SALARY

-------------- --------------- ------------- ------------------

1026 2 Priya 35000

6731 2 Rahul 25400

OUTPUT ANS 8Q:-


COUNT (*)

----------------

OUTPUT ANS 9Q:-


MIN (SALARY)

--------------------

25400

OUTPUT ANS 9Q:-


MAX (SALARY)

--------------------

35000

OUTPUT ANS 9Q:-


AVG (SALARY)

--------------------

30200

OUTPUT ANS 10Q:-


EMP-ID DEPT_ID NAME SALARY

-------------- --------------- ------------- ------------------

1238 3 Surya 45000

OUTPUT ANS 11Q:-


Name

-----------------
Account

OUTPUT ANS 12 Q i):-


EMP-ID DEPT_ID NAME SALARY

------------- -------------- -------------- ---------------

1238 3 Surya 51750

OUTPUT ANS 13Q:-


EMP-ID DEPT_ID NAME SALARY BONUS

-------------- --------------- ------------- ------------------ -------------

1009 1 Arun 25000 1250

1026 2 Priya 35000 1750

1238 3 Surya 51750 2588

1555 4 keerthi 15000 750

6731 2 Rahul 25400 1270

OUTPUT ANS 14Q i):-


EMP-ID DEPT_ID NAME SALARY

-------------- --------------- ------------- ------------------

1009 1 Arun 25000

1026 2 Priya 35000

1238 3 Surya 51750

6731 2 Rahul 25400

======end======
SQL -4

1. Create database for the bank transaction.


i. Create customer table
A. Described the table
ii. Create the bank table
A. Described the table

2. Command to insert record to the customer table

3. Command to list all the record for customer table.

4. Command to insert record to the bank table

5. Command to list all the record for customer table.

6. Check trdate equal to and greater than ‘01-MAR-2022’

7. Check trdate only greater than ‘01-MAR-2022’

8. Join the 2 tables customer and bank.

9. List and count for trdates

10. Delete a row from table bank.

11. List cno number which is unique in the table

12. Create view name as SEE only 2 attribute such as cno, cphone from costomer

13. Command to display the create view

14. Command to list all the cname by descending order.

ANS 1Q i)

SQL> create table customer (cno number(4) primary key, cname char(14), caddress
varchar(20), cphone char(12));

ANS 1Q i. A)

SQL> desc customer;

ANS 1Q ii)

SQL> create table bank (accno number(8) not null, tramount number98), trdate date, trtype
char, cno number(4));

ANS 1Q ii A)

SQL> desc bank;


ANS 2Q

SQL> insert into customer values ( 100,'anush','bangalore','25552');

SQL> insert into customer values ( 101,'ganes','hubli','36545')

SQL> insert into customer values ( 102,'kiran','mysore','78564');

ANS 3Q

SQL> select * from customer;

ANS 4Q

SQL> insert into bank values ( 1300, 2396, '01-MAR-2022', 'D' , 100);

SQL> insert into bank values ( 13101, 7000, '26-MAR-2022', 'C' , 100);

SQL> insert into bank values ( 13102, 2400, '01-JAN-2022', 'C' , 102);

SQL> insert into bank values ( 13103, 5968, '14-FEB-2022', 'D' , 103);

ANS 5Q

SQL> select * from bank;

ANS 6Q

SQL> select * from bank where trdate='01-mar-2022' and trdate>'01-mar-2022';

no rows selected

ANS 7Q

SQL> select * from bank where trdate>='01-mar-2022';

ANS 8Q

SQL>select bank.accno, customer.cno from customer, bank where customer.cno=banck.cno;

ANS 9Q

SQL> select trtype, count(*) from bank group by trtype;

ANS 10Q

SQL> delete from bank where accno=1300;

1 row delete.

ANS 11Q

SQL> select distinct (cno) from bank;

ANS 12 Q

SQL> create view SEE as select cno, cphone from customer;

view created.
NOTE
take print out and past it in un-rule page

OUTPUT ANS 1Q i A ) :-
NAME NULL? TYPE

--------------------- --------------------- ----------------------------

CNO NOT NULL NUMBER(4)

CNAME CHAR(14)

CADDRESS VARCHAR(20)

CPHONE CHAR(12)

OUTPUT ANS 1Q ii. A):-


NAME NULL? TYPE

------------ --------------------- ------------------

ACCNO NOT NULL NUMBER(8)

TRAMOUNT NUMBER(8)

TRADATE DATE

TRTYPE CHAR

CNO NUMBER(4)

OUTPUT ANS 3Q :-
CNO CNAME CADDRESS CPHONE

-------- ------------- ----------------------- ------------------

100 anush Bangalore 25552

101 ganes hubli 36545

102 kiran mysore 78564


OUTPUT ANS 5Q:-
ACCNO TRAMOUNT TRDATE CNO

---------------- ---------------------- --------------------- ---------------

1300 2396 01-MAR-22 100

13101 7000 26-MAR-22 100

13102 2400 21-JAN-22 102

13103 5968 14-FEB-22 103

OUTPUT ANS 7Q:-


ACCNO TRAMOUNT TRDATE TRTYPE CNO

----------- -------------------- ------------------- ------------- ------------

1300 2396 01-MAR-22 D 100

13101 7000 26-MAR-22 C 100

OUTPUT ANS 8Q:-


ACCNO CNO

------------- --------------

1300 100

13101 100

13102 102

OUTPUT ANS 9Q:-


TRTYPE COUNT(*)

--------------- ---------------

D 2

C 2

OUTPUT ANS 11Q:-


CNO

---------------

100

102
103

ANS 13Q

SQL> select * from see;

OUTPUT ANS 13Q:-

CNO CPHONE

---------------- -----------------

100 25552

101 36545

102 78564

ANS 14 Q

SQL>select cname from customer order by cname desc;

OUTPUT ANS 14Q:-


CNAME

--------------

kiran

ganes

anush

======end======
HTML 01
Write a html program to create a student time table.

<HTML>
<body text = "BLACK" bgcolor="WHITE">
<center>
<font face =" time new roman " size = "16" color= "BLACK">
Best P.U College <br>
</font>
<b> Bangalore </b> <br><hr>
TIME TABLE
</center>

<center> <table border = "12" color="blue">


<caption align="right" > for commerce students</caption>

<tr bgcolor = "WHITE">


<th> day </th>
<th> 10:00 - 11:00 </th>
<th> 11:00 - 12:00 </th>
<th> 12:00 - 01:00 </th>
<th> 01:00 - 01:30 </th>
<th> 01:30 - 02:30 </th>
<th> 02:30 - 03:30 </th>
<th> 03:30 - 04:30 </th>
</tr>

<TR>
<TD> <B> MONDAY </B> </TD>
<TD> COMPUTER SCIENCE </TD>
<TD> BUSINESS STUDIES </TD>
<TD> ENGLISH </TD>
<TD> </TD>
<TD> ACCOUNTANCY </TD>
<TD> ECONOMICS </TD>
<TD> LAB </TD>
</TR>

<TR>
<TD> <B> TUESDAY </B> </TD>
<TD> COMPUTER SCIENCE </TD>
<TD> ECONOMICS </TD>
<TD> ENGLISH </TD>
<TD> BREAK </TD>
<TD> ACCOUNTANCY </TD>
<TD> KANNADA </TD>
<TD> LAB </TD>
</TR>
<TR>
<TD> <B> WEDNESDAY </B> </TD>
<TD> ECONOMICS </TD>
<TD> KANNADA </TD>
<TD> BUSINESS STUDIES </TD>
<TD> BREAK </TD>
<TD> COMPUTER SCIENCE </TD>
<TD> ENGLISH </TD>
<TD> LAB </TD>

</TR>

<TR>
<TD> <B> THURSDAY </B> </TD>
<TD> ACCOUNTANCY </TD>
<TD> ENGLISH </TD>
<TD> ECONOMICS </TD>
<TD> BREAK </TD>
<TD> COMPUTER SCIENCE </TD>
<TD> KANNADA </TD>
<TD> LAB </TD>
</TR>

<TR>
<TD> <B> FRIDAY </B> </TD>
<TD> COMPUTER SCIENCE </TD>
<TD> BUSINESS STUDIES </TD>
<TD> ENGLISH </TD>
<TD> BREAK </TD>
<TD> ACCOUNTANCY </TD>
<TD> ECONOMICS </TD>
<TD> LAB </TD>
</TR>

<TR>
<TD> <B> SATURDAY </B> </TD>
<TD> KANNADA</TD>
<TD> BUSINESS STUDIES </TD>
<TD> VALUE ADDED COURSE </TD>
<TD> BREAK </TD>
<TD> ENGLISH </TD>
<TD> MORAL SCIENCE </TD>
<TD> LAB </TD>
</TR>

</table>
</center>
</body>
</html>
======end======
HTML 02
Application Form

<!DOCTYPE html>

<body text =”BLACK” >


<b>Application Form</b>
<table style = “width : 100%” border = “1”>
<form>

<tr>
<td> Student Name : </td>
<td><input type="text" Name=”sname “></td>
</tr>

<tr>
<td> Father Name : </td>
<td><input type="text" Name=”Fname “></td>
</tr>

<tr>
<td> Date of Birth : </td>
<td><input type="text" Name=”dob“></td>
</tr>

<tr>
<td> Sex : </td>
<td><input type="radio" Name=”sex “ value = “Male “> Male
<input type="radio" Name=”sex “ value = “Female “> Female
</td>
</tr>

<tr>
<td>Qualifying Examination : </td>
<td><input type="text" Name=”percent“></td>
</tr>

<tr>
<td> Correspondence Address : </td>
<td><input type="text" Name=”add“></td>
</tr>

<tr>
<td> Contact Number : </td>
<td><input type="text" Name=”phone“></td>
</tr>

<tr>
<td> E-Mail : </td>
<td><input type="text" Name=”E-Mail“></td>
</tr>
<tr>
<td align = “left “> select the course : </td>
<td align = “left” >

<input type = “text “ name = “commination “>


<select name = “ dropdown “>

<option value = “PCMC”> PCMC </option>


<option value = “PCMB”> PCMB </option>
<option value = “PCME”> PCME </option>
</select>

</td>
</tr>

<tr>
<td align = “right”> <button type = “button "> submit </button> </td>
<td align = “left”> <button type = “button “> cancel </button> </td>
</tr>

</table>
</form>
</body>
</html>

======end======

You might also like