0% found this document useful (0 votes)
47 views24 pages

Hsslive Xii Comp App Com Solved Lab Work Binukumar 2023 24

Uploaded by

anatchacko9
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
47 views24 pages

Hsslive Xii Comp App Com Solved Lab Work Binukumar 2023 24

Uploaded by

anatchacko9
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 24

Join Now: https://join.hsslive.in Downloaded from https://www.hsslive.

in ®

SOLVED LAB WORK OF COMPUTER APPLICATIONS(COMMERCE)


2023-24
1. Input three numbers and find the largest.

#include<iostream>
using namespace std;
int main()
{
int a,b,c;
cout<<"Find the largest number among three\n\n\n";
cout<<"Enter three numbers :";
cin>>a>>b>>c;
if((a>b) && (a>c))
cout<<"The largest number is :"<<a;
else if(b>c)
cout<<"The largest number is :"<<b;
else
cout<<"The largest number is :"<<c;
return 0;
}

OUTPUT

Find the largest number among three

Enter three numbers :23 76 54


The largest number is :76

2. Input the principal amount, type of account (C for current a/c or S for SB a/c) and number of years, and
display the amount of interest. Rate of interest for current a/c is 8.5% and that of SB a/c is 6.5%.

#include<iostream>
using namespace std;
int main()
{
int am,yr;
char ty;
float cint,sint;
cout<<"Enter the principle amount :\n";
cin>>am;
cout<<"Enter the type of account(c for current and s for savings)\n";
cin>>ty;
cout<<"Enter the number of years (period of deposit) :";
cin>>yr;
cint=(am*8.5/100)*yr;
sint=(am*6.5/100)*yr;
if((ty=='c') || (ty=='C'))

Prepared by Binu Kumar V V, HSSTComputer Science, NSS HSS Mundathicode for Hsslive.in Page No:1
Join Now: https://join.hsslive.in Downloaded from https://www.hsslive.in ®

cout<<"The rate of interest (Current Account) :"<<cint;


else if((ty=='s') || (ty=='S'))
cout<<"the rate of interest (Savings) :"<<sint;
return 0;
}

OUTPUT

Enter the principle amount :


1000
Enter the type of account(c for current and s for savings)
c
Enter the number of years (period of deposit) :2
The rate of interest (Current Account) :170

Enter the principle amount :


1000
Enter the type of account(c for current and s for savings)
s
Enter the number of years (period of deposit) :2
the rate of interest (Savings) :130

3. Input a digit and display the same in word. (Zero for 0, One for 1, …., Nine for 9)
#include <iostream>
using namespace std;
int main()
{
long int n,sum=0,r;
cout<<"Enter the Number= ";
cin>>n;
while(n>0)
{
r=n%10;
sum=sum*10+r;
n=n/10;
}
n=sum;
while(n>0)
{
r=n%10;

Prepared by Binu Kumar V V, HSSTComputer Science, NSS HSS Mundathicode for Hsslive.in Page No:2
Join Now: https://join.hsslive.in Downloaded from https://www.hsslive.in ®

switch(r)
{
case 1:
cout<<"one ";
break;
case 2:
cout<<"two ";
break;
case 3:
cout<<"three ";
break;
case 4:
cout<<"four ";
break;
case 5:
cout<<"five ";
break;
case 6:
cout<<"six ";
break;
case 7:
cout<<"seven ";
break;
case 8:
cout<<"eight ";
break;
case 9:
cout<<"nine ";
break;
case 0:
cout<<"zero ";
break;
default:
cout<<"not valid";
break;
}
n=n/10;
}
}

OUTPUT
Enter the Number= 485
four eight five

Prepared by Binu Kumar V V, HSSTComputer Science, NSS HSS Mundathicode for Hsslive.in Page No:3
Join Now: https://join.hsslive.in Downloaded from https://www.hsslive.in ®

4. Find the sum of the first N natural numbers without using formula.
#include <iostream>
using namespace std;
int main()
{
int n,i,sum=0;
cout<<"sum of First n Natural numbers\n";
cout<<"Input a number\t";
cin>>n;
for(i=1;i<=n;i++)
{
sum=sum+i;
}
cout<<" Answer = "<<sum;
}

OUTPUT
sum of First n Natural numbers

Input a number 10
Answer = 55

5. Input an integer number and check whether it is palindrome or not.


#include <iostream>
using namespace std;

int main()
{
int n, num, digit, rev = 0;

cout << "Enter a positive number: ";


cin >> num;

n = num;

do
{
digit = num % 10;
rev = (rev * 10) + digit;
num = num / 10;
} while (num != 0);

cout << " The reverse of the number is: " << rev << endl;

Prepared by Binu Kumar V V, HSSTComputer Science, NSS HSS Mundathicode for Hsslive.in Page No:4
Join Now: https://join.hsslive.in Downloaded from https://www.hsslive.in ®

if (n == rev)
cout << " The number is a palindrome.";
else
cout << " The number is not a palindrome.";

return 0;
}

OUTPUT

Enter a positive number: 1456


The reverse of the number is: 6541
The number is not a palindrome.

Enter a positive number: 14541


The reverse of the number is: 14541
The number is a palindrome.

6. Display the multiplication table of a number having 12 rows.

#include <iostream>
using namespace std;

int main()
{
int a;
cout<<"Enter a number :";
cin>>a;
for(int i=1;i<=12;i++)
cout<<i<<" X "<<a<<" = "<<i*a<<"\n";
return 0;
}

OUTPUT

Enter a number :5
1X5=5
2 X 5 = 10
3 X 5 = 15
4 X 5 = 20
5 X 5 = 25
6 X 5 = 30
7 X 5 = 35
8 X 5 = 40

Prepared by Binu Kumar V V, HSSTComputer Science, NSS HSS Mundathicode for Hsslive.in Page No:5
Join Now: https://join.hsslive.in Downloaded from https://www.hsslive.in ®

9 X 5 = 45
10 X 5 = 50
11 X 5 = 55
12 X 5 = 60

7. Create an array to store the heights of 10 students and find the largest value.

#include <iostream>
using namespace std;

int main()
{
int i;
int arr[10];
cout <<"Enter the heights of 10 students ";

for(i=0;i<10;i++)
{
cin>>arr[i];

for(i=1;i<10;++i)
{
if(arr[0]<arr[i])
arr[0]=arr[i];
}
cout<<endl<<"Largest student with height = "<<arr[0];

return 0;
}

OUTPUT

Enter the heights of 10 students 14 15 12 14 18 15 17 16 24 15

Largest student with height = 24

8. Find the length of a string without using strlen() function.

#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
char ar[15];

Prepared by Binu Kumar V V, HSSTComputer Science, NSS HSS Mundathicode for Hsslive.in Page No:6
Join Now: https://join.hsslive.in Downloaded from https://www.hsslive.in ®

int c=0;
cout<<"Enter a string :";
cin>>ar;
for(int i=0;ar[i]!='\0';i++)
{
c++;
}
cout<<"The length of the given string is :"<<c;
return 0;
}

OUTPUT

Enter a string :MUNDATHICODE


The length of the given string is :12

9. Find the factorial of a number with the help of a user-defined function.

#include<iostream>
using namespace std;
void fact(int n)
{
int m=1;
for(int i=1;i<=n;i++)
m=m*i;
cout<<"The factorial of "<<n<<" is "<<m;
}
int main()
{
int num;
cout<<"Enter the number :";
cin>>num;
fact(num);
return 0;
}

OUTPUT

Enter the number :5


The factorial of 5 is 120

Prepared by Binu Kumar V V, HSSTComputer Science, NSS HSS Mundathicode for Hsslive.in Page No:7
Join Now: https://join.hsslive.in Downloaded from https://www.hsslive.in ®

10. Input two numbers and swap them with the help of a user defined function.

#include<iostream>
using namespace std;

void swap(int ,int );


int main()
{
int a,b;
cout<<"Enter the Two Numbers to Swap in C++: ";
cin>>a>>b;
cout<<"\nAfter Swapping of Two Numbers:";
swap(a,b);
return 0;
}
void swap(int x,int y)
{
int z;
z=x;
x=y;
y=z;
cout<<" "<<x<<" "<<y;

OUTPUT

Enter the Two Numbers to Swap in C++: 12 16

After Swapping of Two Numbers: 16 12

Developing HTML documents

11. Design a simple and attractive web page for Kerala Tourism. It should contain features like background
colour/image, headings, text formatting and font tags, images, etc .

<html>
<body bgcolor="cyan">
<center>
<img src="tourism.jpg" height="200" width="250">
<font color="red" size=10>
<h1>Kearala Tourism web page</h1>

Prepared by Binu Kumar V V, HSSTComputer Science, NSS HSS Mundathicode for Hsslive.in Page No:8
Join Now: https://join.hsslive.in Downloaded from https://www.hsslive.in ®

</font></center>
<p align="center">
Lush Hill stations<br>
Wild life sancturies<br>
backwater resorts<br>
</p>
<h2><u><i>Tourism Locations</i></u></h2>
<img src="thekkady.jpg" height="150" width="200">
<img src="Munnar.jpg" height="150" width="200">
<img src="Wayanad.jpg" height="150" width="200"><br>
For more inforation contact us
</body>
</html>

OUTPUT

12. Design a simple webpage about your school. Create another webpage named address.htm containing
the school address. Give links from school page to address.htm and reverse.

School.html

<html>
<body bgcolor="cyan">
<center>
<h1>NSS HSS MUNDATHIKODE</h1>
<font color="red" size="6">
My school is located in Mundathicode, Thrissur
<h2>You can find the address by using the following link</h2>
</font>

Prepared by Binu Kumar V V, HSSTComputer Science, NSS HSS Mundathicode for Hsslive.in Page No:9
Join Now: https://join.hsslive.in Downloaded from https://www.hsslive.in ®

<br>
<a href="address.html">school address</a>
</center>
</body>
</html>
address.html

<html>
<body bgcolor="yellow">
<center>
<h1>
NSS HSS Mundathicode<br>
Higher Secondary School<br>
Mundathicode wesp PO<br>
Thrissur<br>
Ph 4885286650
<a href="school.html">Go Home</a>
</h1>
</center>
</body>
</html>

OUTPUT

Prepared by Binu Kumar V V, HSSTComputer Science, NSS HSS Mundathicode for Hsslive.in Page No:10
Join Now: https://join.hsslive.in Downloaded from https://www.hsslive.in ®

13. Design a webpage as shown below using appropriate list tags.

Permanent members in UN Security Council


 Russia
 China
 USA
 UK
 France

<html>
<body bgcolor="yellow">
<h2>Permanent members in UN Security Council </h2>
<ul>
<li>Russia</li>
<li>China</li>
<li>USA</li>
<li>UK</li>
<li>France</li>
</ul>
</body>
</html>

Prepared by Binu Kumar V V, HSSTComputer Science, NSS HSS Mundathicode for Hsslive.in Page No:11
Join Now: https://join.hsslive.in Downloaded from https://www.hsslive.in ®

OUTPUT

14. Design a webpage as shown below using appropriate list tag.

Wild life Sanctuaries in Kerala


1. Eravikulam
2. Periyar
3. Chinnar
4. Wayanad

<html>
<body bgcolor="yellow">
<h2>Wild life Sanctuaries in Kerala </h2>
<ol>
<li>Eravikulam</li>
<li>Periyar</li>
<li>Chinnar</li>
<li>Wayanad</li>

</ol>
</body>
</html>

Prepared by Binu Kumar V V, HSSTComputer Science, NSS HSS Mundathicode for Hsslive.in Page No:12
Join Now: https://join.hsslive.in Downloaded from https://www.hsslive.in ®

OUTPUT

15. Design a web page containing a table as shown below.

Speed Limits in Kerala


Vehicles Near School (In Within Corporation/ State Highway (In
Km/hour) Municipality (In Km/hour)
Km/hour)
Motor Cycle 30 50 50
Motor Car 30 50 80
Light motor vehicles 30 50 80
Heavy motor vehicles 30 40 65

<html>

<body bgcolor="yellow">
<b>SPEED LIMITS IN KERALA</b><br>
<table border="2">
<tr><th>Vehicles</th><th>Near School <br>(In Km/hour)</th><th>Within Corporation/<br> Municipality<br> (In

Km/hour)</th><th>State Highway <br>(In Km/hour)</th></tr>


<tr align="center"><td>Motor Cycle</td><td>30</td><td>50</td><td>50</td></tr>
<tr align="center"><td>Motor Car</td><td>30</td><td>50</td><td>80</td></tr>
<tr align="center"><td>Light motor vehicles</td><td>30</td><td>50</td><td>80</td></tr>

Prepared by Binu Kumar V V, HSSTComputer Science, NSS HSS Mundathicode for Hsslive.in Page No:13
Join Now: https://join.hsslive.in Downloaded from https://www.hsslive.in ®

<tr align="center"><td>Heavy motor vehicles</td><td>30</td><td>40</td><td>65</td></tr>


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

OUTPUT

16. Design a simple web page as shown below.

<html>
<body bgcolor="yellow">
<form name="f1" action="school.html">
<h4>Client Login</h4>

Enter User name &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" name="t1">


<br><br>
Enter your Password &nbsp;<input type="password" name="t2">
<br><br>
<input type="submit"> <input type="reset" value="Clear">

Prepared by Binu Kumar V V, HSSTComputer Science, NSS HSS Mundathicode for Hsslive.in Page No:14
Join Now: https://join.hsslive.in Downloaded from https://www.hsslive.in ®

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

OUPUT

Database queries using MySQL


17. Create a table Student with the following fields and insert at least 5 records into the table except for the column Total.

Roll No Int Primary key


Name Varchar(25)
Batch Varchar(25)
Mark1 Int
Mark 2 Int
Mark3 Int
Total Int

a. Update the column Total with the sum of Mark1, Mark2 and Mark3.

b. List the details of students in Commerce batch.

c. Display the name and total marks of students who are failed (Total < 90).

d. Display the name of students in alphabetical order and in batch based.

OUTPUT
mysql> create database school;
Query OK, 1 row affected (0.06 sec)

mysql> use school;


Database changed

Prepared by Binu Kumar V V, HSSTComputer Science, NSS HSS Mundathicode for Hsslive.in Page No:15
Join Now: https://join.hsslive.in Downloaded from https://www.hsslive.in ®

mysql> create table student(roll_no int primary key,name varchar(25),batch


varchar(25),mark1 int,mark2 int,mark3 int,total int);
Query OK, 0 rows affected (0.08 sec)

mysql> insert into student values(1,'Binu','CS',98,99,85,null);


Query OK, 1 row affected (0.00 sec)

mysql> insert into student values(2,'Shyam','COM',97,99,95,null);


Query OK, 1 row affected (0.06 sec)

mysql> insert into student values(3,'Vimal','COM',55,65,78,null);


Query OK, 1 row affected (0.00 sec)

mysql> insert into student values(4,'Vignesh','CS',95,65,98,null);


Query OK, 1 row affected (0.00 sec)

mysql> insert into student values(5,'Sanjay','CS',12,25,20,null);


Query OK, 1 row affected (0.00 sec)

mysql> select * from student;


+---------+---------+-------+-------+-------+-------+-------+
| roll_no | name | batch | mark1 | mark2 | mark3 | total |
+---------+---------+-------+-------+-------+-------+-------+
| 1 | Binu | CS | 98 | 99 | 85 | NULL |
| 2 | Shyam | COM | 97 | 99 | 95 | NULL |
| 3 | Vimal | COM | 55 | 65 | 78 | NULL |
| 4 | Vignesh | CS | 95 | 65 | 98 | NULL |
| 5 | Sanjay | CS | 12 | 25 | 20 | NULL |
+---------+---------+-------+-------+-------+-------+-------+

mysql> update student set total=mark1+mark2+mark3;


Query OK, 5 rows affected (0.00 sec)
Rows matched: 5 Changed: 5 Warnings: 0

mysql> select * from student;


+---------+---------+-------+-------+-------+-------+-------+
| roll_no | name | batch | mark1 | mark2 | mark3 | total |
+---------+---------+-------+-------+-------+-------+-------+
| 1 | Binu | CS | 98 | 99 | 85 | 282 |
| 2 | Shyam | COM | 97 | 99 | 95 | 291 |
| 3 | Vimal | COM | 55 | 65 | 78 | 198 |
| 4 | Vignesh | CS | 95 | 65 | 98 | 258 |
| 5 | Sanjay | CS | 12 | 25 | 20 | 57 |
+---------+---------+-------+-------+-------+-------+-------+

Prepared by Binu Kumar V V, HSSTComputer Science, NSS HSS Mundathicode for Hsslive.in Page No:16
Join Now: https://join.hsslive.in Downloaded from https://www.hsslive.in ®

mysql> select * from student where batch='COM';


+---------+-------+-------+-------+-------+-------+-------+
| roll_no | name | batch | mark1 | mark2 | mark3 | total |
+---------+-------+-------+-------+-------+-------+-------+
| 2 | Shyam | COM | 97 | 99 | 95 | 291 |
| 3 | Vimal | COM | 55 | 65 | 78 | 198 |
+---------+-------+-------+-------+-------+-------+-------+

mysql> select name,total from student where total<90;


+--------+-------+
| name | total |
+--------+-------+
| Sanjay | 57 |
+--------+-------+

mysql> select name,batch from student order by name asc;


+---------+-------+
| name | batch |
+---------+-------+
| Binu | CS |
| Sanjay | CS |
| Shyam | COM |
| Vignesh | CS |
| Vimal | COM |
+---------+-------+

18. Create a table named "Employee" with the following fields and insert at least 5 records except the column named
gross_pay and DA.

emp_code Int primary key


Emp_name Varchar(20)
Designation Varchar(20)
Department Varchar(25)
Basic Decimal(10,2)
Da Decimal(10,2)
Gross_pay Decimal(10,2)

->Update DA with 15% of the Basic pay


->Display the details of the employee in sales and HR department
->Update the gross pay with the sum of DA and Basic pay
->Display the details of the employee with gross pay below 10000

mysql> use school;


Database changed
mysql> create table employee(emp_code integer primary key,emp_name
varchar(20),designation varchar(25),department varchar(25),basic decimal(10,2),da
decimal(10,2),gross_pay decimal(10,2));
Query OK, 0 rows affected (0.13 sec)

Prepared by Binu Kumar V V, HSSTComputer Science, NSS HSS Mundathicode for Hsslive.in Page No:17
Join Now: https://join.hsslive.in Downloaded from https://www.hsslive.in ®

mysql> desc employee;


+-------------+---------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------+---------------+------+-----+---------+-------+
| emp_code | int(11) | | PRI | 0 | |
| emp_name | varchar(20) | YES | | NULL | |
| designation | varchar(25) | YES | | NULL | |
| department | varchar(25) | YES | | NULL | |
| basic | decimal(10,2) | YES | | NULL | |
| da | decimal(10,2) | YES | | NULL | |
| gross_pay | decimal(10,2) | YES | | NULL | |
+-------------+---------------+------+-----+---------+-------+

mysql> insert into employee values(1,"Binu","Manager","Sales",25000,null,null);


Query OK, 1 row affected (0.05 sec)

mysql> insert into employee values(2,"Archana","manager","Sales",23000,null,null);


Query OK, 1 row affected (0.07 sec)

mysql> insert into employee values(3,"Gayathri","clerk","office staff",5000,null,null);


Query OK, 1 row affected (0.00 sec)

mysql> insert into employee values(4,"Aryan","Asst Manager","HR",26000,null,null);


Query OK, 1 row affected (0.00 sec)
mysql> insert into employee values(5,"krishna","clerk","office staff",6000,null,null);
Query OK, 1 row affected (0.00 sec)

mysql> select * from employee;


+----------+----------+--------------+--------------+----------+------+----------
| emp_code | emp_name | designation | department | basic | da | gross_pay |
+----------+----------+--------------+--------------+----------+------+----------
| 1 | Binu | Manager | Sales | 25000.00 | NULL | NULL |
| 2 | Archana | manager | Sales | 23000.00 | NULL | NULL |
| 3 | Gayathri | clerk | office staff | 5000.00 | NULL | NULL |
| 4 | Aryan | Asst Manager | HR | 26000.00 | NULL | NULL |
| 5 | krishna | clerk | office staff | 6000.00 | NULL | NULL |
+----------+----------+-------------+--------------+----------+------+-----------

mysql> update employee set da=basic*75/100;

Query OK, 5 rows affected (0.05 sec)

Rows matched: 5 Changed: 5 Warnings: 0

Prepared by Binu Kumar V V, HSSTComputer Science, NSS HSS Mundathicode for Hsslive.in Page No:18
Join Now: https://join.hsslive.in Downloaded from https://www.hsslive.in ®

mysql> select * from employee;

+----------+----------+--------------+--------------+----------+----------+-----------+

| emp_code | emp_name | designation | department | basic | da | gross_pay |

+----------+----------+--------------+--------------+----------+----------+-----------+

| 1 | Binu | Manager | Sales | 25000.00 | 18750.00 | NULL |

| 2 | Archana | manager | Sales | 23000.00 | 17250.00 | NULL |

| 4 | Aryan | Asst Manager | HR | 26000.00 | 19500.00 | NULL |

| 5 | krishna | clerk | office staff | 6000.00 | 4500.00 | NULL |

| 3 | Gayathri | clerk | office staff | 5000.00 | 3750.00 | NULL |

+----------+----------+--------------+--------------+----------+----------+-----------+

mysql> select * from employee where department in("sales","hr","purchase");

+----------+----------+--------------+------------+----------+----------+-----------+

| emp_code | emp_name | designation | department | basic | da | gross_pay |

+----------+----------+--------------+------------+----------+----------+-----------+

| 1 | Binu | Manager | Sales | 25000.00 | 18750.00 | NULL |

| 2 | Archana | manager | Sales | 23000.00 | 17250.00 | NULL |

| 4 | Aryan | Asst Manager | HR | 26000.00 | 19500.00 | NULL |

+----------+----------+--------------+------------+----------+----------+-----------+

mysql> update employee set gross_pay=basic+da;

Query OK, 5 rows affected (0.00 sec)

Rows matched: 5 Changed: 5 Warnings: 0

mysql> select * from employee;

+----------+----------+--------------+--------------+----------+----------+-----------+

| emp_code | emp_name | designation | department | basic | da | gross_pay |

+----------+----------+--------------+--------------+----------+----------+-----------+

| 1 | Binu | Manager | Sales | 25000.00 | 18750.00 | 43750.00 |

| 2 | Archana | mabager | Sales | 23000.00 | 17250.00 | 40250.00 |

| 4 | Aryan | Asst Manager | HR | 26000.00 | 19500.00 | 45500.00 |

Prepared by Binu Kumar V V, HSSTComputer Science, NSS HSS Mundathicode for Hsslive.in Page No:19
Join Now: https://join.hsslive.in Downloaded from https://www.hsslive.in ®

| 5 | krishna | clerk | office staff | 6000.00 | 4500.00 | 10500.00 |

| 3 | Gayathri | clerk | office staff | 5000.00 | 3750.00 | 8750.00 |

+----------+----------+--------------+--------------+----------+----------+-----------+

mysql> select * from employee where gross_pay<10000;

+----------+----------+-------------+--------------+---------+---------+-----------+

| emp_code | emp_name | designation | department | basic | da | gross_pay |

+----------+----------+-------------+--------------+---------+---------+-----------+

| 3 | Gayathri | clerk | office staff | 5000.00 | 3750.00 | 8750.00 |

+----------+----------+-------------+--------------+---------+---------+-----------+

19. Create a table Stock, which stores daily sales of items in a shop, with the following fields and insert at least 5 records into the
table.

Item_code Integer Primary key


Item_name Varchar (20)
Manufacturer_Code Varchar (5)
Qty Integer
Unit_Price Decimal (10,2)

a. Display the item names with stock zero.


b. Display the number of items manufactured by the same manufacturer
c. Display the highest price and lowest quantity in the stock.
d. Increase the unit price of all items by 10%.

mysql> create table stock(item_code int primary key,item_name varchar(20),man_code


varchar(5),qty integer, price decimal(10,2));
Query OK, 0 rows affected (0.03 sec)

mysql> desc stock;


+-----------+---------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------+---------------+------+-----+---------+-------+
| item_code | int(11) | | PRI | 0 | |
| item_name | varchar(20) | YES | | NULL | |
| man_code | varchar(5) | YES | | NULL | |
| qty | int(11) | YES | | NULL | |
| price | decimal(10,2) | YES | | NULL | |
+-----------+---------------+------+-----+---------+-------+
5 rows in set (0.00 sec)

mysql> insert into stock values(100,'laptop','hp',100,25000);


Query OK, 1 row affected (0.00 sec)

mysql> insert into stock values(101,'desktop',10,15000);


ERROR 1136: Column count doesn't match value count at row 1

Prepared by Binu Kumar V V, HSSTComputer Science, NSS HSS Mundathicode for Hsslive.in Page No:20
Join Now: https://join.hsslive.in Downloaded from https://www.hsslive.in ®

mysql> insert into stock values(101,'desktop','dell',10,15000);


Query OK, 1 row affected (0.00 sec)

mysql> insert into stock values(102,'printer','dell',103,5000);


Query OK, 1 row affected (0.00 sec)

mysql> insert into stock values(104,'scanner','dell',0,35000);


Query OK, 1 row affected (0.00 sec)

mysql> insert into stock values(105,'laptop','acer',50,35000);


Query OK, 1 row affected (0.00 sec)

mysql> select * from stock;


+-----------+-----------+----------+------+----------+
| item_code | item_name | man_code | qty | price |
+-----------+-----------+----------+------+----------+
| 100 | laptop | hp | 100 | 25000.00 |
| 101 | desktop | dell | 10 | 15000.00 |
| 102 | printer | dell | 103 | 5000.00 |
| 104 | scanner | dell | 0 | 35000.00 |
| 105 | laptop | acer | 50 | 35000.00 |
+-----------+-----------+----------+------+----------+
5 rows in set (0.00 sec)

mysql> select item_name from stock where qty=0;


+-----------+
| item_name |
+-----------+
| scanner |
+-----------+

mysql> select item_name,count(*) from stock group by man_code;


+-----------+----------+
| item_name | count(*) |
+-----------+----------+
| laptop | 1 |
| desktop | 3 |
| laptop | 1 |
+-----------+----------+

mysql> select max(price),min(qty) from stock;


+------------+----------+
| max(price) | min(qty) |
+------------+----------+
| 35000.00 | 0 |
+------------+----------+
1 row in set (0.06 sec)

mysql> update stock set price=price+price*10/100;


Query OK, 5 rows affected (0.00 sec)
Rows matched: 5 Changed: 5 Warnings: 0

Prepared by Binu Kumar V V, HSSTComputer Science, NSS HSS Mundathicode for Hsslive.in Page No:21
Join Now: https://join.hsslive.in Downloaded from https://www.hsslive.in ®

mysql> select * from stock;


+-----------+-----------+----------+------+----------+
| item_code | item_name | man_code | qty | price |
+-----------+-----------+----------+------+----------+
| 100 | laptop | hp | 100 | 27500.00 |
| 101 | desktop | dell | 10 | 16500.00 |
| 102 | printer | dell | 103 | 5500.00 |
| 104 | scanner | dell | 0 | 38500.00 |
| 105 | laptop | acer | 50 | 38500.00 |
+-----------+-----------+----------+------+----------+
5 rows in set (0.00 sec)

20. Create a table Bank with the following fields and insert at least 5 records into the table.

acc_no integer primary key


acc-name varchar(25)
branch_name varchar(25)
acc_type varchar(25)
amount decimal(10,2)

a. Display the account details of "Savings Account" in Kodungallur branch.


b . Change the branch name "Trivandrum" to "Thiruvananthapuram".
c. Display the details of customers in Thiruvananthapuram, Ernakulam and Kozhikode
d. List the details of customers in Thrissur branch having a minimum balance of Rs. 5000.

mysql> create table bank(acc_no int primary key,acc_name varchar(20),branch_name


varchar(20),acc_type varchar(20),amount decimal(10,2));
Query OK, 0 rows affected (0.02 sec)

mysql> desc bank;


+-------------+---------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------+---------------+------+-----+---------+-------+
| acc_no | int(11) | | PRI | 0 | |
| acc_name | varchar(20) | YES | | NULL | |
| branch_name | varchar(20) | YES | | NULL | |
| acc_type | varchar(20) | YES | | NULL | |
| amount | decimal(10,2) | YES | | NULL | |
+-------------+---------------+------+-----+---------+-------+

mysql> insert into bank values(121,'Binu','Kodungallur','savings',25000);

Query OK, 1 row affected (0.00 sec)

mysql> insert into bank values(122,'Shyam','Trivandrum','savings',5000);

Query OK, 1 row affected (0.00 sec)

Prepared by Binu Kumar V V, HSSTComputer Science, NSS HSS Mundathicode for Hsslive.in Page No:22
Join Now: https://join.hsslive.in Downloaded from https://www.hsslive.in ®

mysql> insert into bank values(123,'Arun','Kozhikkodu','savings',55000);

Query OK, 1 row affected (0.00 sec)

mysql> insert into bank values(124,'Sarath','thrissur','savings',75000);

Query OK, 1 row affected (0.00 sec)

mysql> insert into bank values(125,'Hari','thrissur','savings',4000);

Query OK, 1 row affected (0.00 sec)

mysql> select * from bank;

+--------+----------+-------------+----------+----------+

| acc_no | acc_name | branch_name | acc_type | amount |

+--------+----------+-------------+----------+----------+

| 121 | Binu | Kodungallur | savings | 25000.00 |

| 122 | Shyam | Trivandrum | savings | 5000.00 |

| 123 | Arun | Kozhikkodu | savings | 55000.00 |

| 124 | Sarath | thrissur | savings | 75000.00 |

| 125 | Hari | thrissur | savings | 4000.00 |

+--------+----------+-------------+----------+----------+

5 rows in set (0.00 sec)

mysql> select * from bank where branch_name='kodungallur';

+--------+----------+-------------+----------+----------+

| acc_no | acc_name | branch_name | acc_type | amount |

+--------+----------+-------------+----------+----------+

| 121 | Binu | Kodungallur | savings | 25000.00 |

+--------+----------+-------------+----------+----------+

mysql> update bank set branch_name='Thiruvananthapuram' where branch_name='Trivandrum';

Query OK, 1 row affected (0.00 sec)

Prepared by Binu Kumar V V, HSSTComputer Science, NSS HSS Mundathicode for Hsslive.in Page No:23
Join Now: https://join.hsslive.in Downloaded from https://www.hsslive.in ®

Rows matched: 1 Changed: 1 Warnings: 0

mysql> select * from bank;

+--------+----------+--------------------+----------+----------+

| acc_no | acc_name | branch_name | acc_type | amount |

+--------+----------+--------------------+----------+----------+

| 121 | Binu | Kodungallur | savings | 25000.00 |

| 122 | Shyam | Thiruvananthapuram | savings | 5000.00 |

| 123 | Arun | Kozhikkodu | savings | 55000.00 |

| 124 | Sarath | thrissur | savings | 75000.00 |

| 125 | Hari | thrissur | savings | 4000.00 |

+--------+----------+--------------------+----------+----------+

mysql> select acc_name,acc_no from bank where branch_name='thrissur' OR


branch_name='kodungallur';

+----------+--------+

| acc_name | acc_no |

+----------+--------+

| Binu | 121 |

| Sarath | 124 |

| Hari | 125 |

+----------+--------+

mysql> select * from bank where amount<5000 and branch_name='thrissur';

+--------+----------+-------------+----------+---------+

| acc_no | acc_name | branch_name | acc_type | amount |

+--------+----------+-------------+----------+---------+

| 125 | Hari | thrissur | savings | 4000.00 |

+--------+----------+-------------+----------+---------+

1 row in set (0.00 sec)

Prepared by Binu Kumar V V, HSSTComputer Science, NSS HSS Mundathicode for Hsslive.in Page No:24

You might also like