0% found this document useful (0 votes)
2 views20 pages

Programs - Practical

The document contains various C++ programs, HTML designs, JavaScript functions, and SQL queries aimed at teaching computer applications. Each section includes specific aims, code snippets, and explanations for tasks such as checking number properties, displaying multiplication tables, creating web pages, and managing student records in a database. The programs cover fundamental programming concepts and web development techniques.
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)
2 views20 pages

Programs - Practical

The document contains various C++ programs, HTML designs, JavaScript functions, and SQL queries aimed at teaching computer applications. Each section includes specific aims, code snippets, and explanations for tasks such as checking number properties, displaying multiplication tables, creating web pages, and managing student records in a database. The programs cover fundamental programming concepts and web development techniques.
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

C++ PROGRAMS –COMPUTER APPLICATIONS

[Link] Negative or zero

Aim:Input a number and check whether it is postive,negative or zero.

#include<iostream>
using namespace std;
int main()
{
int a ;
cout<<"Enter a number:";
cin>>a;
if(a>0)
{cout<<"Positive Number \n";
}
else if (a==0)
{cout<<"zero \n";
}
else
{
cout<<"Negative Number \n";
}}

[Link] table

Aim:Display the multiplication table of a number having 12 rows

#include<iostream>
using namespace std;
int main()
{
int num,i,result;
cout<<"Enter a number :";
cin>>num;
cout<<"multiplication table of :"<<num;
for(i=1;i<=12;i++)
{
result=i*num;
cout<<"\n"<<i<<" x "<<num<<"="<<result;
}}

[Link] of students

Aim:find average height of N students using an array.

#include<iostream>
using namespace std;
int main()
{
int a[100],i,avg,sum=0,n;
cout<<"Enter the number of students :";
cin>>n;
for(i=0;i<n;i++)
{
cout<<"Enter the height of "<<i+1<<" student :";
cin>>a[i];
sum=sum+a[i];
}
avg =sum/n;
cout<<"\n Average height="<<avg<<"\n"; }
[Link] of three numbers

Aim:Input three numbers and find the largest


#include<iostream>
using namespace std;
int main()
{
int a,b,c;
cout<<"Enter three numbers:\n";
cin>>a>>b>>c;
if(a>b)
{
if(a>c)
{
cout<<"largest="<<a;
}
else
{
cout<<"largest="<<c;
}}
else if(b>c)
{
cout<<"largest="<<b;
}
else
{
cout<<"largest="<<c;
}
}
[Link] of the day

Aim:Assume that January 1 is [Link] a program using switch to display the name of the day
when we input a day number in that month.

#include<iostream>
using namespace std;
int main()
{
int num,r;
cout<<"Enter day 1 to 31";
cin>>num;
if(num>31)
cout<<"Wrong choice";
else
{
r=num%7;
switch(r)
{
case 1:
cout <<"Monday\n";
break;

case 2:
cout <<"Tuesday\n";
break;

case 3:
cout <<"Wednesday\n";
break;

case 4:
cout <<"Thursday\n";
break;

case 5:
cout <<"Friday\n";
break;

case 6:
cout <<"Saturday\n";
break;

case 0:
cout <<"Sunday\n";
break;
}}}

6. Factorial of a Number

Aim: Find the factorial of a number with the help of a user defined function

#include<iostream>
#include<iostream>
using namespace std;
long factorial(int n);
int main()
{
int n;
cout<<"Enter a Number ";
cin>>n;
cout<<"Factorial="<<factorial (n) <<"\n";
return 0;
}
long factorial(int n)

{
long fact =1;
for(int counter =1;counter<=n;counter++)
{
fact=fact*counter;
}
return fact;
}

[Link]

Aim: Write a c++ program to display following pattern.

*****
****
***
**
*
#include<iostream>
using namespace std;
int main()
{
int max,i,j;
cout<<"Enter the maximum *";
cin>>max;
for(j=0;j<max;j++)
{
cout<<"\n";
for(i=0;i<max-j;i++)
{
cout<<"*\t";
}}
cout<<"\n";
}
[Link] of the Squares

Find the sum of the squares of the first N natural numbers without using formula

#include<iostream>
using namespace std;
int main()
{
int num,square,sum=0,i;
cout<<"Enter the limit:";
cin>>num;
for(i=1;i<=num;i++)
{
square=i*i;
sum=sum+square;
}
cout<<"sum of square fo first "<<num<<" natural number="<<sum<<"\n";
}
9 . SWAPPING USING USER DEFINED FUNCTION - CALL BY REFERENCE

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

#include<iostream>
using namespace std;
void swap(int &x,int &y)
{
int t;
t=x;
x=y;
y=t;
}

int main()
{

int a,b;
cout<<”Enter the values of a and b”;
cin>>a>>b;
cout<<”\n Before Swap \n”;
cout<<”a=”<<a<<”\t b=”<<b;​
swap(a,b);
cout<<”\n After swap \n”;
cout<<”a=”<<a<<”\t b=”<<b;

return 0;

[Link] Mark using a user defined function

Aim:Read admission number,name and marks of three subjects of a [Link] a function


named calc() to calculate average mark.

#include<iostream>
#include<stdio.h>
using namespace std;
int calc(int x1,int x2,int x3);
int main()
{
int adno,m1,m2,m3,Average;
char name[15];
cout<<"\n Enter admission number";
cin>>adno;
cout<<"\n Enter name";
cin>>name;
cout<<"\nEnter marks of three subjects";
cin>>m1>>m2>>m3;
Average=calc(m1,m2,m3);
cout<<"\n Admission no :"<<adno<<"\n Name :"<<name<<"\n Average mark:"<<Average;
cout<<"\n";
}
int calc(int x1,int x2,int x3)
{
int t;
t=(x1+x2+x3)/3;
return t;
}
HTML PROGRAMS

1. Kerala state –Design a simple attractive webpage for kerala state.

<html>
<head>
<title> kerala</title>
<head>
<body bgcolor =”green” text=”blue”>
<h1 align=”center”>KERALA STATE</h1>
<font color=”red” size=”24”>Welcome to god’s own country</font>
<br>
<h3>Tourist places</h3>
<br>
Kovalam
Ponmudi
Munnar
<br>
<img src=”[Link]”>
</body>
</html>

2. Department of tourism –Design a webpage showing tourist destinations in kerala.

<html>
<head>
<title>Tourist destinations of kerala</title>
<?head>
<body>
<h1 align=”center”>DEPARTMENT OF TOURISM</h1>
<br>
<h3>Tourist destinations in Kerala</h3>
<ul>
<li>Beach </li>
<ol >
<li >Kovalam
<li>Muzhappilangad
<li>Kappad
</ol>

<li>Hill stations <li>


<ol >
<li>Munnar
<li>Wayanad
<li>Gavi
</ol>

<li>Wild life
<ol >
<li>Iravikulam
<li>Muthanga
<li>Kadalundi
</ol>
</ul>

</body>
</html>
3. Table-Design the given table using HTML Procedure
class Strength

Science Commerce Humanities

Plus one 49 50 48

Plus two 50 50 49

<html>
<head>
<title> Table design</title>
</head>
<body>
<table border=”1”>
<tr>
<td rowspan =”2” align= “center”>Class</td>
<td colspan =”3” align =”center”>strength</td>
</tr>
<tr>
<td >Science</td>
<td >Commerce</td>
<td >Humanities</td>
</tr>
<tr>
<td >Plus one</td>
<td >49</td>
<td >50</td>
<td >48</td>
</tr>
<tr>
<td>Plus Two</td>
<td >50</td>
<td >50</td>
<td >49</td>
</tr>

<table>
</body>
</html>
4. Table Text book- Design a webpage that displays the indent for Plus two text books as given
below.
Section Book Name Quantity

Language English 100

Malayalam 100

Commerce Accountancy 80

Business Studies 90

Economics 85

Computer applications 100

<html>
<head>
<title>Text book requirements</title>
</head>
<body>
<table width =”320”boder =”1”>
<tr>
<td align=”center”><b>Section</b></td>
<td align=”center”><b> Book Name</td>
<td align=”center”><b>Quantity</b></td>
</tr>
<tr>
<td rowspan=”2” align =”center”>Language</d>
<td>English</td>
<td align =”center”>100</td>
</tr>
<tr>
<td>Malayalam</tr>
<td align=”center”>100</td>
</tr>
<tr>
<td rowspan=”4” align=”center”>Commerce</td>
<td>Accountancy</td>
<td align=”center”>80</td>
</tr>
<tr>
<td>Business Studies</td>
<td align=”center”>90</td>
</tr>
<tr>
<td>Economics </td>
<td align=”center”>85</td>
</tr>
<tr>
<td>Computer Application</td>
<td align=”center”>100</td>
</tr>
</table>
</body>
</html>

HTML Program 5 –LINKING


Aim: Design a simple webpage about your school. Create another webpage named [Link]
containing the school address. Give links from school page to address page.

[Link]
<html>
<head>
<title>School </title>
</head>
<body>
<h1 align=”center”>My school</h1>
<h2 >[Link]’s HSS Edoor</h2>
<a href=”[Link]”>
Click to see the address</a>
</body>
</html>

[Link]

<html>
<head>
<title>Address </title>
</head>
<body>
<h1 align=”center”>My school Address</h1>
<h2 >[Link]’s HSS Edoor</h2>
<h3>Aralam P.O</h3>
<h4>Kannur Dt</h4>
<h5 >670 704</h1>
</body>
</html>
HTML Program 6 –FRAME TEAM

Aim:Design a webpage containing frames that divide the screen vertically in the ratio 50:[Link]
two webpages-one containing the list of cricket team members other containing a list of football
team members

[Link]
<html>
<head>
<title>Cricket Team </title>
</head>
<body>
<h1 align=”center”>CRICKET TEAM</h1>
<ul>
<li> Raina</li>
<li> Kohli</li>
<li> Balagi</li>
<li> [Link]</li>
<li> Yuvaraj</li>
<li> Pathan</li>
<li> [Link]</li>
<li> Bumrah</li>
<li> Harbajan</li>
<li> [Link]</li>

</ul>
</body>
</html>

[Link]

<html>
<head>
<title>Football Team </title>
</head>
<body>
<h1 align=”center”>FOOTBALL TEAM</h1>
<ul>

<li> Modal</li>
<li> Rino Anto</li>
<li> CK Vineeth</li>
<li> [Link]</li>
<li> Lalvuthara</li>
<li> Sonu Sigh</li>
<li> Jinkan</li>
<li> Subrata</li>
<li> rishab</li>
<li> [Link]</li>

</ul>
</body>
</html>

[Link]
<html>
<head>
<title>Cricket and Football Team</title>
</head>
<frameset cols=”50%,50%”
<frame src=”[Link]”>
<frame src=”[Link]”>
<frameset>
</html>

HTML Program 7 - Client Login


[Link] a simple webpage containing a simple Login form
<html>
<head>
<title>Design a simple webpage <title>
</head>
<body>
<h1 align=”center”>Client Login</h1>
<form>
<center>
Enter User Name
<input name =”pass” type =”password”>
<br>

<input name =”sub” type =”submit” value=”Submit”>


<input name =”rst” type =”reset” value =”clear”>
</center>
</form>
</body>
</html>

JAVASCRIPT PROGRAMS

[Link] OR EVEN

<html>
<head>
<title> first javascript </title>
<script language="javascript">
function check()
{
var x;
x=[Link];

if(x%2==0)
{
[Link]="Even";
}
else
{
[Link]="Odd";
}
}
</script>
</head>
<body>
<form name ="form1">
<h3 align ="center">Find Even Odd </h3>
<center>
Enter a number
<input type ="text" name="first">
<p>
result
<input type ="text" name="second">
<p>
<input type ="button" name="sub" value="show" onclick="check()">
</center>

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

[Link] OF A NUMBER

<html>
<head>
<title> first javascript </title>
<script language="javascript">
function check()
{
var x,y;

x=[Link];
y=x*x;
[Link]=y
}
</script>
</head>
<body>
<form name ="form1">
<h3 align ="center">Find Squre of A Number </h3>
<center>
Enter a number
<input type ="text" name="first">
<p>
result
<input type ="text" name="second">
<p>
<input type ="button" name="sub" value="show" onclick="check()">
<input type ="reset" value="clear" >
</center>

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

[Link] OF A NUMBER

<html>
<head>
<title> first javascript </title>
<script language="javascript">
function check()
{
var x,s=1,n;
x=[Link];

for(n=1;n<=x;n++)
{
s=s*n;
}

[Link]=s;
}

</script>
</head>
<body>
<form name ="form1">
<h3 align ="center">Find Even Odd </h3>
<center>
Enter a number
<input type ="text" name="first">
<p>
result
<input type ="text" name="second">
<p>
<input type ="button" name="sub" value="show" onclick="check()">
</center>
</form>
</body>
</html>

SQL PROGRAMS

MYSQL 1
STUDENT TABLE -1

Aim

Create a table student with fields

Roll No Integer Primary key Name Character(25) Batch varchar(25) Mark1 int Mark2 int Mark3 int
Total int

Write SQL Queries to

a. Update the column Total with 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 and batch of those students who scored 90 or more in Mark1 and Mark2
e. Delete the student who scored below 30 in Mark3

Procedure

[Link] create database with name school.

Create database school;

2. select database .

Use school;

[Link] create a table student with fields.

Create table student(Roll_Number integer primary key,Name Varchar(25),batch varchar(20),mark1


int,mark2 int,mark2 int,Total int );

[Link] insert data in the fields (6 records)

insert into student values (2,’karuna,’science’,64,56,46,NULL);

insert into student values (3,’aruna,’science’,64,56,46,NULL);

insert into student values (4,’runa,’commerce’,54,56,46,NULL);


insert into student values (5,’karuna,’science’,64,16,46,NULL);
insert into student values (6,’karuna,’science’,24,26,16,NULL);

[Link] display the content of the table name student

Select *from student;

[Link] update field total with the sum of Mark1,Mark2,Mark3

Update student set Total=Mark1+mark2+Mark3;

[Link] details of student in Commerce batch

Select *from student where (Batch=’commerce’);

[Link] name and total mark of student who are failed(Total<90)

Select*from student where (total<90)

[Link] the name and batch of those students who scored 50 or in Mark1 and Mark2.

Select name,batch from student where(mark1>50 and Mark2>50);

[Link] the student who scored below 30 in Mark3.

Delete from student where(mark3<30);

MYSQL 2

Student Table- 2

Aim

Create a table student with fields

Roll No Integer Primary key Name Character(25) Batch varchar(25) Mark1 int Mark2 int Mark3 int
Total int

Write SQL Queries to

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


b. List the details of students in science batch in ascending order of their names.
c. Display the highest Total in Humanities batch
d. List the details of students who passed (Subject minimum is 30 and aggregate minimum is
90)the course.
e. Delete the students of commerce batch who failed in any one subject.

Procedure

[Link] create database with name school.

Create database school;

2. select database .
Use school;

[Link] create a table student with fields.

Create table student(Roll_Number integer primary key,Name Varchar(25),batch varchar(20),mark1


int,mark2 int,mark2 int,Total int );

[Link] insert data in the fields (6 records)

insert into student values (2,’karuna,’science’,64,56,46,NULL);

insert into student values (3,’aruna,’science’,64,56,46,NULL);

insert into student values (4,’runa,’commerce’,54,56,46,NULL);

insert into student values (5,’karuna,’science’,64,16,46,NULL);

insert into student values (6,’karuna,’science’,24,26,16,NULL);

[Link] display the content of the table name student

Select *from student;

[Link] update field total with the sum of Mark1,Mark2,Mark3

Update student set Total=Mark1+mark2+Mark3;

[Link] the details of students in science batch in the ascending order of their names.

Select*from student where(Batch=’science’)order by name asc;

[Link] highest total in Humanities batch.

Select batch,max(total)from student where (batch=’humanities’);

[Link] the details of students who passed(subject minimum is 30 and aggregate minimum is 90)the
course.
Select*from student where(mark1>=30 and mark2>=30 and mark3>=30 and total>=90);

[Link] the students commerce batch who failed in any one subject.

Delete from student where ((mark1<30 or mark2<30 or mark3<30) and Batch=’commerce’);

MYSQL 3

STUDENT TABLE- 3

Aim
Create a table student with fields

Roll No Integer Primary key Name Character(25) Batch varchar(25) Mark1 int Mark2 int Mark3 int
Total int

Write SQL Queries to

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


b. Add a new column Average to the table student.
c. Update the details of students who has highest total.
d. List the details of students who has the highest Total.

Procedure

[Link] create database with name school.

Create database school;

2. select database .

Use school;

[Link] create a table student with fields.

Create table student(Roll_Number integer primary key,Name Varchar(25),batch varchar(20),mark1


int,mark2 int,mark2 int,Total int );

[Link] insert data in the fields (6 records)

insert into student values (2,’karuna,’science’,64,56,46,NULL);

insert into student values (3,’aruna,’science’,64,56,46,NULL);

insert into student values (4,’runa,’commerce’,54,56,46,NULL);


insert into student values (5,’karuna,’science’,64,16,46,NULL);

insert into student values (6,’karuna,’science’,24,26,16,NULL);

[Link] display the content of the table name student

Select *from student;

[Link] update field total with the sum of Mark1,Mark2,Mark3

Update student set Total=Mark1+mark2+Mark3;

[Link] a new column Average to the table student.

Alter student add average float.

[Link] the column average with average marks.

Update student set average=total/3;

Select *from student;


[Link] the details of students who has highest total

Select*from student where(total=(select max(total)from student));

[Link] the details of students who passed(subject minimum is 30 and aggregate minimum is 90)the
course.

Select*from student where(mark1>=30 and mark2>=30 and mark3>=30 and total>=90);

MYSQL 4

EMPLOYYE TABLE -1

Aim

create a table employee with the following fields and insert at least 5 records into the table except
the column GrossPay and DA.

Emp_code Int primary key,Emp_name varchar(20),Designation Varchar(25),Department


varchar(25),Basic Dec(20,2),Gross_pay Dec(10,2)

a) Update DA with 75% of Basic

b) display the details of employees in Purchase,Sales and HR departments.

c)Display the details employee with gross pay below 10000.

d)Delete all the clerks from the table.

Procedure

[Link] create a table named Employee.


Create table Employee (Emp_code int primary key,Emp_name varchar(25),Designation
varchar(25),Department varchar(25),Basic dec(10,2),DA decimal(10,2),Gross_pay decimal(10,2));

[Link] data in the fields

Insert into employee values(1,’Krishnan,’manager’,’HR’,50000,NULL,NULL);

Insert into employee values(2,’Raman,’manager’,’Purchase’,35000,NULL,NULL);

Insert into employee values(3,’Lakshmanan,’clerk’,’Sales’,25000,NULL,NULL);

Insert into employee values(4,’Bharathan,’driver,’Sales’,5000,NULL,NULL);

Insert into employee values(5,’Seetha,’clerk’,’Accounts’,5000,NULL,NULL);

Insert into employee values(2,’Krishnan,’manager’,’HR’,50000,NULL,NULL);

[Link] DA with 75% of the Basic Pay

Update employee set DA=Basic*70/100;

[Link] Gross as the sum of BasicPay and DA

Update employee set Gross_Pay=DA+Basic;


[Link] details of employees in Purchase,Sales and HR Departments.

Select*from employee where(Department=’HR or department=’Purchase’ OR department=’sales’);

[Link] the details employee with gross pay below 10000

Select*from employee where(Gross_Pay<10000);

[Link] all the clerks from a table.

Delete from employee where (Designation=’clerk’);

MYSQL 5

Employee table 5

Aim

create a table employee with the following fields and insert at least 5 records into the table except
the column GrossPay and DA.

Emp_code Int primary key,Emp_name varchar(20),Designation Varchar(25),Department


varchar(25),Basic Dec(20,2),Gross_pay Dec(10,2)
a) Update DA with 75% of Basic
b) Update the Gross_pay with sum of Basic and DA
c) display the details of employees in Purchase,Sales and HR departments
d) find the number of employees in Account department
e) delete the details of clerks whose gross pay is below 20,000.
[Link] create a table named Employee.

Create table Employee (Emp_code int primary key,Emp_name varchar(25),Designation


varchar(25),Department varchar(25),Basic dec(10,2),DA decimal(10,2),Gross_pay decimal(10,2));

[Link] data in the fields

Insert into employee values(1,’Krishnan,’manager’,’HR’,50000,NULL,NULL);

Insert into employee values(2,’Raman,’manager’,’Purchase’,35000,NULL,NULL);

Insert into employee values(3,’Lakshmanan,’clerk’,’Sales’,25000,NULL,NULL);

Insert into employee values(4,’Bharathan,’driver,’Sales’,5000,NULL,NULL);

Insert into employee values(5,’Seetha,’clerk’,’Accounts’,5000,NULL,NULL);

Insert into employee values(2,’Krishnan,’manager’,’HR’,50000,NULL,NULL);

[Link] DA with 75% of the Basic Pay

Update employee set DA=Basic*70/100;


[Link] Gross as the sum of BasicPay and DA

Update employee set Gross_Pay=DA+Basic;

[Link] details of employees in Purchase,Sales and HR Departments.

Select*from employee where(Department=’HR or department=’Purchase’ OR department=’sales’);

[Link] the number of employees in Accounts departments

Select count(*),department from employee group by department having department=’Accounts’);

[Link] all the clerks whose Gross pay is below 20000

Delete from employee where (Designation=’clerk’ and Gross_Pay<20000);

Prepared by basilcs@[Link]

You might also like