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

CA Programs

The document contains a series of programming examples in C++, HTML, and SQL, showcasing various functionalities such as checking if a number is positive, finding the largest among three numbers, displaying digits in words, and creating web pages with tables and lists. It also includes SQL queries for creating tables, inserting records, updating data, and retrieving specific information from databases. Each program is structured with an aim, procedure, and code snippets demonstrating the implementation of the described functionality.

Uploaded by

athulpvmenachoy
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 views11 pages

CA Programs

The document contains a series of programming examples in C++, HTML, and SQL, showcasing various functionalities such as checking if a number is positive, finding the largest among three numbers, displaying digits in words, and creating web pages with tables and lists. It also includes SQL queries for creating tables, inserting records, updating data, and retrieving specific information from databases. Each program is structured with an aim, procedure, and code snippets demonstrating the implementation of the described functionality.

Uploaded by

athulpvmenachoy
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

Pgm No: 1 POSITIVE, NEGATIVE OR ZERO

AIM: Input a number and check whether it is positive, negative or zero


PROCEDURE:
#include <iostream>
using namespace std;
int main()
{
int num;
cout<<”Enter a number \n”;
cin>>num;
if(num>0)
{
cout<<”Positive number \n”;
}
else if(num<0)
{
cout<<”Negative number \n”;
}
else
{
cout<<”Zero”;
}
return 0;
}

Pgm No: 2 LARGEST AMONG THREE NUMBERS


AIM: Input three numbers and find the largest.
PROCEDURE:
#include <iostream>
using namespace std;
int main()
{
int a,b,c;
cout<<”enter 3 numbers\n”;
cin>>a>>b>>c;
if(a>b && a>c)
cout<<a<<” is large”;
else if (b>c)
cout<<b<<”is large”;
else
cout<<c<<” is large”;
return 0;
}

Pgm No: 3 NUMBER IN WORDS


AIM: Input a digit and display the corresponding word using switch.
PROCEDURE:
#include <iostream>
using namespace std;
int main()
{
int digit;
cout << "Enter a digit(0-9)”;
cin >>digit ;
switch (digit)
{
case 0: cout<<”zero”;
break;
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;
default: cout << "Wrong input";
}
return 0;
}
Pgm No:4 SUM OF DIGITS OF A NUMBER
AIM: Find the sum of digits of an integer number
PROCEDURE:
#include <iostream>
using namespace std;
int main()
{
int num,rem,sum=0;
cout<<”Enter a number\n”;
cin>>num;
while(num>0)
{
rem=num%10;
sum=sum+rem;
num=num/10;
}
cout<<”Sum of digit=”<<sum<<”\n”;
return 0;
}

Pgm No: 5 MULTIPLICATION TABLE

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


PROCEDURE:
#include <iostream>
using namespace std;
int main()
{
int num,i,result;
cout<<”enter a number\n”;
cin>>num;
for(i=1;i<=10;i++)
{
result=i*num;
cout<<”\n”<<i<<”x”<<num<<”=”<<result;
}
return 0;
}

Pgm No: 6 SUM OF SQUARES OF FIRST N NUMBERS

AIM:Find the sum of the squares of the first N natural numbers without using formula
PROCEDURE:
#include <iostream>
using namespace std;
int main()
{
int num,square,sum=0,i;
cout<<"enter the limit\n";
cin>>num;
for(i=1;i<=num;i++)
{
square=i*i;
sum=sum+square;
}
cout<<"sum of squares = "<<sum<<"\n";
return 0;
}
Pgm No: 7 AVERAGE HEIGHT
AIM: Input the heights of 8 students and find the average height.
PROCEDURE:
#include <iostream>
using namespace std;
int main()
{
int a[20],i,sum=0,avg;
cout<<"\n enter the heights of 8 students \n";
for(i=0;i<8;i++)
{
cin>>a[i];
sum=sum+a[i];
}
avg=sum/8;
cout<<"Average height of 8 students= "<< avg;
return 0;
}

Pgm No: 8 DISPLAY 10 TO 1


AIM: To print 10 to 1.
PROCEDURE:
#include <iostream>
using namespace std;
int main()
{
int i;
cout<<”Numbers from 10 to 1 \n”;
for(i=10;i>=1;i--)
{
cout<<i<<”\t”;
}
}

Pgm No: 9 DISPLAY EVEN NUMBERS FROM 1 TO 100


AIM: To print even numbers from 1 to 100.
PROCEDURE:
#include <iostream>
using namespace std;
int main()
{
int i;
for(i=2; i<=100;i=i+2)
{
cout<<i<<"\t";
}
}

Pgm No: 10 PALINDROME OR NOT


AIM: To check whether a number is palindrome or not
PROCEDURE:
#include <iostream>
using namespace std;
int main()
{
int n,num,rev=0,r;
cout<<"enter a number\n";
cin>>num;
n=num;
while(num>0)
{
r=num%10;
rev=rev*10+r;
num=num/10;
}
if(n==rev)
cout<<"Number is palindrome\n";
else
cout<<"Number is not palindrome";
}

HTML
Pgm No: KERALA TOURISM
AIM: Design a simple and attractive webpage for Kerala Tourism. It should contain features like background
colour/image, headings, text formatting and font tags, images, etc.
PROCEDURE:
<html>
<head>
<title>Kerala</title>
</head>
<body bgcolor="#112233" text="blue">
<center>
<font size="7" color="red"> Kerala state </font>
<h1 align="center"> Welcome to God’s own country </h1><br>
<h3>Tourist places</h3>
<br>
<b>Varkala</b><br>
<i>Kovalam</i><br>
<u>Bepoor</u><br>
<big>Ponmudi</big><br>
<img src="[Link]" alt="an image" height="350" width="350" border="1"></center>
</body>
</html>
*******************************************
Pgm No:2 SCHOOL WEBSITE
AIM:
Write an HTML code to create two web pages one about your school and other about your class, create a link
from the school web page to the class web page.
PROCEDURE:
[Link]
<html>
<head>
<title>Address</title>
</head>
<body>
<h1>My School</h1>
<h2>IJM Higher Secondary School</h2>
<a href="[Link]">Click to see the class</a>
</body>
</html>

[Link]
<html>
<head>
<title>Class</title>
</head>
<body>
<h1>Plus Two Commerce</h1>
<h2>Subjects</h2>
<h3>English</h3>
<h3>Second Language</h3>
<h3>Business Studies</h3>
<h3>Accountancy</h3>
<h3>Economics</h3>
<h3>Computer Application</h3>

</body>
</html>
****************************************************

Pgm No: 3 TABLE


AIM: Design a web page containing a table as shown below.

Speed limits in Kerala


Vehicles Near School Within Corporation/ In other Muncipality
(in Km/hour) roads (in Km/hour)
(in Km/hour)
Motor Cycle 25 40 50
Light motor 25 40 60
vehicles
Heavy motor 15 35 60
vehicles

PROCEDURE:
<html>
<head>
<title> Design a web page contain table </title>
</head>
<body>

<table border="1" width=500>


<caption>Speed limits in Kerala</caption>
<tr>
<th>Vehicles </th>
<th>Near School(in Km/hour)</th>
<th>Within Corporation/In other roads(in Km/hour)</th>
<th>Municipality(in Km/hour)</th>
</tr>
<tr>
<th>Motor Cycle</th>
<td>25 </td>
<td>40 </td>
<td>50 </td>
</tr>
<tr>
<th>Light motor vehicles</th>
<td>25 </td>
<td>40 </td>
<td>60 </td>
</tr>
<tr>
<th>Heavy motor vehicles</th>
<td>15 </td>
<td>35 </td>
<td>60 </td>
</tr>
</table>
</body>
</html>

Pgm No: 4 UNORDERED LIST


AIM: Design a web page as shown below using appropriate list tag.
Bird Sanctuaries in Kerala
• Kadalundi
• Thattekad
• Mangalvanam

PROCEDURE
<html>
<head>
<title>unordered list</title>
</head>
<body >
<h1> Bird Sanctuaries in Kerala </h1>
<ul>
<li> Kadalundi </li>
<li> Thattekad </li>
<li> Mangalvanam</li>
</ul>
</body>
</html>

Pgm No: 5 ORDERED LIST


AIM: Design a webpage having a list as shown below.
Stages in web hosting
1. Selection of hosting type
2. Purchase hosting space
3. Register a domain name
4. Transfer website files
5. Configure DNS
PROCEDURE
<html>
<head>
<title>ordered list tag </title>
</head>
<body>
<h1> Stages in web hosting</h1>
<ol >
<li>Selection of hosting type </li>
<li> Purchase hosting space </li>
<li> Register a domain name </li>
<li> Transfer website files </li>
<li> Configure DNS </li>
</ol>
</body>
</html>

Pgm No:6 TABLE 2


AIM:
Design the following table using HTML.
Terrestrial Planet (Source: NASA)
Planet Day Length (in earth hours) Year Length (in earth days)
Mercury 1480 88
Venus 5832 224.7
Earth 24 365.26
Mars 25 687

PROCEDURE:
<html>
<head>
<title>Table Design</title>
</head>
<body>
<b>Terrestrial Planet (Source: NASA)</b>
<table border="1">
<tr>
<th>Planet</th>
<th>Day Length (in earth hours)</th>
<th>Year Length (in earth days)</th>
</tr>
<tr>
<td>Mercury</td>
<td>1480</td>
<td>88</td>
</tr>
<tr>
<td>Venus</td>
<td>5832</td>
<td>224.7</td>
</tr>
<tr>
<td>Earth</td>
<td>24</td>
<td>365.26</td>
</tr>
<tr>
<td>Mars</td>
<td>25</td>
<td>687</td>
</tr>

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

SQL- Structured Query Language.

1. Create a table Student with the following fields and insert at least 5 records into the table except for the
column Total.
rollno integer primary key
name varchar(25)
sub1 integer (0 -100)
sub2 integer
sub3 integer
total integer
a) Insert data in the fields rollno, name, sub1,sub2, sub3 (At least 5 records)
b) Update the column total with the sum of sub1,sub2,sub3
c) Display highest mark in sub2.
d) Display the name in ascending order.
e) Display the highest total mark in the table.

Query: -creating table


create table student ( rollno integer primary key, name varchar(25), sub1 integer, sub2 integer, sub3
integer, total integer );

Query: a – inserting data.


insert into student values ( 1, ‘anu’, 97, 96, 95, null);
insert into student values ( 2, ‘manu’, 46, 77, 98, null);
insert into student values ( 3, ‘tom’, 14,75,23, null);
insert into student values ( 4, ‘john’, 18, 20, 24, null);
insert into student values ( 5, ‘Sree’, 95,91,94, null);
select * from student.
Query: b – Update the column total with the sum of sub1, sub2, sub3
update student set total= sub1+sub2+sub3;
select * from student;

Query: c - Display highest mark in sub2.


Select max(sub2) from student;

Query: d - Display the name in ascending order.


Select * from student order by name asc;

Query : d - Display the highest total mark in the table.


Select max(total) from student;

2. Create a table Employee with the following fields


empcode integer primary key
name varchar(25)
designation varchar(25) (manager, clerk,salesman)
department varchar(25) (purchase, sales, HR, manufacture, design)
basic decimal(10,2)
DA decimal(10,2)
grosspay decimal(10,2) (Rang 5000 – 100000)
a. Insert data in the fields empcode, name, designation, department, basic, DA (at least 5 records)
b. Update Gross at the sum of Basic and DA
c. Display the department wise listing of all employees in ascending order of name.
d. Display the total salary paid to salesmen.
e. Display the details of employee arranged in the descending order of Gross.

Query:1 -creating table


Create table employee (empno integer primary key, name varchar(25), designation varchar(25),
department varchar(25), basic decimal(10,2), DA decimal(10,2), grosspay decimal(10,2));
desc employee;

Query: a - insert into employee values (100,’John’,’ salesman’,’ purchase’,30000,2000,null);


insert into employee values (101,’Manu’,’ clerk’,’ HR’,35000,2500,null);
insert into employee values (102,’Sree’,’ salesman’,’ manufacture’,35000,2500,null);

Query: b -Update Gross at the sum of Basic and DA


Update employee set grosspay= basic +DA;

Query: c - Display the department wise listing of all employees in ascending order of name.
Select * from employee order by department, name;

Query: d -Display the total salary paid to salesmen.


Select sum(grosspay) from employee where department=’salesman’;

Query: e -Display the details of employee arranged in the descending order of Gross.
Select * from employee order by grosspay desc;

3. Create a table Student with the following fields


rollno integer primary key
name varchar(25)
batch varchar(25)
total integer
Batch have values commerce, science, humanities

Write SQL queries to


a. Insert data into the fields Rollno, Name, Batch, and total(at least 5 records)
b. Display the names of all students in Humanities batch.
c. Display the highest total mark in the table.
d. Display the details of students with Rollno from 2 to 5.
e. Display the details of students in the descending order of total mark.

Query: -creating table


create table student2 ( rollno integer primary key, name varchar(25), batch varchar(25), total integer );
desc student2;

Query: a – inserting data.


insert into student2 values ( 1, ‘anu’, ‘commerce’, 450);
insert into student2 values ( 2, ‘manu’, ‘science’, 439);
insert into student2 values ( 3, ‘tom’, ‘humanities’, 500);
insert into student2 values ( 4, ‘john’, ‘commerce’, 310);
insert into student2 values ( 5, ‘Sree’, ‘science’, 395);

Query: b – Display the names of all students in Humanities batch.


Select name from student2 where batch=’Humanities’;

Query: c –Display the highest total mark in the table.


Select max(total) from student2;

Query: d –Display the details of students with Rollno from 2 to 5.


Select * from student2 where rollno between 2 and 5;
Select * from student2 where rollno in(2,3,4,5);

Query: e –Display the details of students in the descending order of total mark.
Select * from student2 order by total desc;

4. Create a table Bank with the following fields


Accno integer primary key
Name varchar(25)
Branch varchar(25)
Amount integer

Write SQL queries to


a. Insert data in all the fields( At least 5 records)
b. Display the account details of Kozhikode batch.
c. Change the branch name ‘Trivandram’ to ‘Thiruvananthapuram’
d. Display the Names of customers in the Kozhikode, Ernakulam and Thiruvananthapuram
e. List the details of customers in the Thrissur branch with minimum balance mount Rs:1000.

Query:1 -creating table


Create table bank (accno integer primary key, name varchar(20), branch varchar(20), amount integer);
desc bank;

Query: a -
Insert data in all the fields( At least 5 records)
insert into bank values (200,’Manu’,’ kozhikode’,50500);
insert into bank values (230,’Sara’,’ Trivandram’,162500);
insert into bank values (120,’Sayad’,’ thrissur’,1000);

Query: b -Display the account details of Kozhikode batch.


Select * from bank where branch=’kozhikode’;

Query: c -Change the batch name ‘Trivandram’ to ‘Thiruvananthapuram’


Update bank set batch= ‘Thiruvananthapuram’ where batch=’Trivandram’;

Query: d -Display the Names of customers in the Kozhikode, Ernakulam and Thiruvananthapuram
Select name from bank where branch in(‘Kozhikode’, ‘Ernakulam’,’Thiruvananthapuram’);

Query: e -List the details of customers in the Thrissur branch with minimum balance amount Rs:1000.
Select * from bank where branch=’thrissur’ and amount >=1000;

You might also like