PROGRAM – 1
Program in C++ to Add Two Numbers
#include <iostream>
using namespace std;
int main()
{
int first number, second number, sum;
cout << "Enter two integers: ";
cin >> first_number >> second_number;
// sum of two numbers in stored in variable sumOfTwoNumbers
sum = first_number + second_number;
// prints sum
cout << first_number << " + " << second_number << "
= " << sum;
return 0;
}
OUTPUT
PROGRAM -2
Write a Program in C++ Fibonacci Series up to n number of terms.
#include<iostream>
using namespace std;
int main() {
int n, t1 = 0, t2 = 1, nextTerm = 0;
cout << "Enter the number of terms: ";
cin >> n;
cout << "Fibonacci Series: ";
for (int i = 1; i <= n; ++i)
{
// Prints the first two terms.
if(i == 1)
{
cout << t1 << ", ";
continue;
}
if(i == 2)
{
cout << t2 << ", ";
continue;
}
nextTerm = t1 +t2;t1=t2;
t2 = nextTerm;
cout << nextTerm << ", ";
}
return 0;
}
PROGRAM -3
Write a Program to calculate area of rectangle using classes and objects.
#include <iostream>
using namespace std;
class Rectangle {
public:
// Variables required for area calculation
int length;
int breadth;
// Constructor to initialize variables
Rectangle(int len, int brth) : length(len), breadth(brth) {}
// Function to calculate area
int getArea() {
return length * breadth;
}
};
int main() {
// Create object of Rectangle class Rectangle
rect(8, 6);
// Call getArea() function
cout << "Area = " << rect.getArea();
return 0;
}
PROGRAM -4
Write a Program in C++ demonstrate the use of default constructor.
#include <iostream>
using namespace std;
// declare a class
class Wall
{
private:
double length;
public:
// default constructor to initialize variable Wall()
length{5.5} {
cout << "Creating a wall." << endl;
cout << "Length = " << length << endl;
}
};
int main()
{
Wall wall1;
return 0;
}
PROGRAM -5
// C++ program to calculate the average marks of two
students
#include <iostream>
using namespace std;
class Student {
public:
double marks;
// constructor to initialize marks Student(double m)
marks{m}
};
// function that has objects as parameters
double average_marks(Student s1, Student s2) {
// return the average of marks of s1 and s2
return (s1.marks + s2.marks)/2 ;
int main()
Student student1(88.0), student2(56.0);
// pass the objects as arguments
cout << "Average Marks = " << average_marks(student1, student2) << "\n";
return 0;
}
PROGRAM -6
Write a C++ program to declare a class. Declare pointer to class. Initialize and
display the contents of the class member.
#include<iostream>
using namespace std;
class RectangleTest
{
public:
int length, breadth;
public:
void initialize(int len, int bre)
{
length = len;
breadth = bre;
}
int getArea()
{
return 2*length*breadth;
}
void display(){
int area = getArea();
cout<<"\n*** Rectangle Information ***\n";
cout<<"Length = "<<length; cout<<"\
nBreadth = "<<breadth; cout<<"\nArea =
"<<area;
cout<<"\n \n";
}
};
int main()
{
RectangleTest rect, *class_ptr;
HANDLE
color=GetStdHandle(STD_OUTPUT_HANDLE);
class_ptr = ▭
SetConsoleTextAttribute(color, 10 );
//Setting color Green
cout<<"\nUsing member functions access";
SetConsoleTextAttribute(color, 7 );
//Setting color White
class_ptr->initialize(10,5);
class_ptr->display();
SetConsoleTextAttribute(color, 10 );
//Setting color Green
cout<<"\nUsing data members access";
SetConsoleTextAttribute(color, 7 );
//Setting color White
class_ptr->length = 2;
class_ptr->breadth = 3;
class_ptr->initialize(class_ptr->length,class_ptr->breadth);
class_ptr->display();
return 0;
PROGRAM -7
AIM: Create your first web page using notepad in HTML.
CODE:
<html>
<head>
<title>My First Web Page</title>
</head
<body bgcolor="#FFC0CB">
<h1><b>My First Web Page</b></h1>
</body>
</html>
OUTPUT:
PROGRAM -8
AIM: Create the web page with the following constraints an image on the
webpage. a hyperlink to college website (c) a table of marks of IT class
students.
CODE:
<html>
<head>
<title>Experiment No 6</title>
</head>
<body bgcolor="pink">
<marquee>Quality Education as a Highway to Achieve Goals</marquee>
<h1><b>GANGA INSTITUTE OF TECHNOLOGY AND MANAGEMENT,
KABLANA</b></h1>
<p align="center"><img src="https://encrypted tbn0.gstatic.com/images?
q=tbn:ANd9GcQT374y2XfDLFOM-eyW1nGRmkgyaywYHWRkffOj9nkH&s"
width="180" height="200"></p>
<table border="4">
<tr>
<td>Name</td>
<td>Roll No</td>
<td>Subject</td>
</tr>
<tr>
<td>Rajesh</td>
<td>60001</td>
<td>IF</td>
</tr>
</table>
</body>
</html>
OUTPUT:
PROGRAM -9
AIM: Create Resume using html.
CODE:
<html>
<title>Resume</title>
<head>
<h1><b><u><center>Resume</center></u></b></h1>
</head>
<body>
<imgsrc="https://static.vecteezy.com/system/resources/thumbnails/
000/610/202/small/human-20.jpg" width="150" height="120" align="left">
<pre>
<font size="+2">
Name: Amit Kumar
Email-id: amitkumar@gmail.com
Phone no.: 1454654564654
</font>
</pre>
<h3><b><u>Aim</u></b></h3>
<font size="+2">To obtain a responsible position in a reputable
company.</font>
<h3><b><u>Objective</u></b></h3>
<font size="+2">To leverage my skills and experience in
[field/industry] to contribute to the success of an organization.</font>
<h3><b><u>Qualifications</u></b></h3>
<font size="+2">
<ul>
<li>Bachelor's degree in [field]</li>
<li>Proficient in [relevant skills]</li>
<li>[Certifications or additional qualifications]</li>
</ul>
</font>
<h3><b><u>Project Details</u></b></h3>
<font size="+2">
<ul>
<li>Project 1: [Description of Project 1]</li>
<li>Project 2: [Description of Project 2]</li>
<li>Project 3: [Description of Project 3]</li>
</ul>
</font>
<h3><b><u>Hobbies</u></b></h3>
<font size="+2">
<ul>
<li>[Hobby 1]</li>
<li>[Hobby 2]</li>
<li>[Hobby 3]</li>
</ul>
</font>
<h3><b><u>Personal Details</u></b></h3>
<font size="+2">
<ul>
<li>Date of Birth: [Date of Birth]</li>
<li>Address: [Address]</li>
<li>Nationality: [Nationality]</li>
</ul>
</font>
</body>
</html>
OUTPUT:
PROGRAM -10
AIM: Create time table for Savings using html.
CODE:
<html>
<head>
<style>
table, th, td {
border: 1px solid black;
}
</style>
</head>
<body>
<table>
<tr>
<th>Month</th>
<th>Savings</th>
<th>Savings for holiday!</th>
</tr>
<tr>
<td>January</td>
<td>$100</td>
<td rowspan="2">$50</td>
</tr>
<tr>
<td>February</td>
<td>$80</td>
</tr>
<tr>
<td>March</td>
<td>$120</td>
<td>$60</td>
</tr>
</table>
</body>
</html>
OUTPUT:
PROGRAM -11
AIM: Create ordered and unordered list using html.
CODE:
<html>
<body>
<h1>An unordered HTML list</h1>
<ul style="list-style-type:circle">
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ul>
<h2>An ordered HTML list</h2>
<ol>
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ol>
</body>
</html>
OUTPUT:
PROGRAM -12
AIM: Create your Student Web Form for the entry of Student’s information.
CODE:
<html>
<head>
<title>My first Web Page</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="green" text="#99FFFF" link="#00FFFF" alink="#FFFFFF"
vlink="#99CCCC">
<h2 align="center"><b><font size="+2" color="red">STUDENT ID
FORM</font><font size="+2" color="blue"></font></b></h2>
<hr>
<form>
<div align="left">
<font size="3">Student ID:</font> <input type="text" name="text2">
</div>
<div align="left">
<p> </p>
<p>Password: <input type="password"></p>
</div>
<div align="left">
<p> </p>
<p>Sex:
<input type="radio" name="p"><font color="blue">male</font>
<input type="radio" name="p"><font color="blue">female</font>
</p>
</div>
<p> </p>
<p>City:
<select>
<option>Delhi</option>
<option>Haryana</option>
<option>Punjab</option>
</select>
</p>
<p> </p>
<p>Or enter city: <input type="text"></p>
<p> </p>
<p>Branch:
<select>
<option>IT</option>
<option>CSE</option>
<option>ECE</option>
<option>MECH</option>
</select>
</p>
<p> </p>
<p>
<font color="black">
<input type="submit" value="Save on my website">
<input type="reset" value="Clear">
</font>
</p>
</form>
</body>
</html>
OUTPUT: