0% found this document useful (0 votes)
10 views17 pages

CS1 Programs and Otput

The document outlines a series of programming experiments primarily in C++ and Visual Basic, covering topics such as sorting algorithms, class hierarchies, constructors, and basic HTML page creation. Each experiment requires writing code, verifying execution, and obtaining hard copies of the program listings and outputs. The document serves as a guide for students to practice and demonstrate their programming skills through various tasks.

Uploaded by

viraj thukrul
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)
10 views17 pages

CS1 Programs and Otput

The document outlines a series of programming experiments primarily in C++ and Visual Basic, covering topics such as sorting algorithms, class hierarchies, constructors, and basic HTML page creation. Each experiment requires writing code, verifying execution, and obtaining hard copies of the program listings and outputs. The document serves as a guide for students to practice and demonstrate their programming skills through various tasks.

Uploaded by

viraj thukrul
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/ 17

Experiment No. 1 a) Write a program in C++ that first initialize an array off given 10 real numbers.

The
program must sort numbers in ascending/descending order using BUBBLE-SORT method. It should print
given list of numbers as well as the sorted list.

b) Enter the program and verify proper execution on the same Computer.

c) Obtain a hardcopy o the program listing as well as output.


Program 2:

a. Write a function in C++ that exchange data (passing by reference) using swap
function to interchange the given two numbers.
b. Enter the program and verify the execution of the same on computer.
c. Obtain the hardcopy of the program listing as well as output.
d. Complete and Certified Journal
Program 3:
Write a program in C++, that first initializes an array of given 10 sorted integer numbers. The
programmust verify whether a given element belongs this array or not, using BINARY SEARCH
technique. Theelement (to be search) is to be entered at the time of execution. If the number is found, the
program should print” The Number is Found” otherwise it should print “The number is not Found”.

Enter the program and verify proper execution of the same on the computer.

Obtain a hardcopy of the program listing as well as output.


Program 4:- Write a program in C++ that initializes a Ratio class with no parameters, as a default
constructor the program must print the message “OBJECT IS BORN “ during initialization .It should
display the message “NOW X IS ALIVE “, When the first member function Ratio x is called.The program
must display “OBJECT DIES “when the class destructor is called for the object when it reached the end of its
scope.

#include<iostream.h>
#include<conio.h>
class ratio
{
public:
ratio()
{
cout<<”object is born \n”;
}
~ratio()
{
cout<< “object dies \n”;
}
private:
int num,den;
};
void main ()
{
ratio x;
cout<<” now x is alive \n”;
cout<<”at the end of program \n”;
}
program 5:
Write a program in C++ with a complex constructor to add the given two complex numbers.The program
should print the given complex number and their sum.

#include<iostream .h>
#include<conio.h>
class complex
{ float x,y;
public:
complex(){ }
complex(float real,float img)
{x=real; y=img; }
complex operator+(complex);
void display(void);
};
complex complex :: operator +(complex c)
{
complex t;
t.x=x+c.x;
t.y=y+c.y;
return(t);
};
void complex:;display (void)
{ cout<<x<<”+j”<<y<<”\n; }
void main()
{complex c1,c2,c3;
c1=complex(2.5,3.5);
c2=complex(1.6,2.7);
c3=c1+c2;
cout<<”c1=”;
c1.display();
cout<<”c2=”;
c2.display();
cout<<”c3=”;
c3.display();
}
program 6:
Program:- Write a program in c++ to implement the following class hierarchy;
Class student to obtain Roll Number ,Class Test to obtain marks scored in two different subjects,Class sports
to obtain weightage (marks) in sports and Class Result to calculate the marks . The program must print the
roll number ,individual marks obtained in two subject, sports and total marks.

#include <iostream.h>
#include<conio.h>
class students
{
int roll_no;
public:
void get_no(int a)
{
roll_no=a;
}void put_no(void)
{ cout<<”roll_no: 0”<<roll_no;
}
};
class test :public student
{public:
float s1,s2;
public:
void get_marks(float x, float y)
{
s1=x;s2=y;
}
void put_marks(void)
{cout<<”marks obtained :\ns1=”<<s1<<”\ns2=”<<s2;
}
};
class sports
{
public:
int score;

void get_score(int x)
{
score=x;
}
void put_score(void)
{cout<<”sports marks :”<<score;
}
};
class result : public test,public sports
{
float tot;
public:
void display(void)
{tot=s1+s2+score;
put_no();
put_marks();
put_score();
cout<<”total score =”<<tot;
};

void main(){
{
result st1;
st1.get_no(101);
st1.get_marks(39,65);
st1.get_score(29);
st1.display();
}

Program 7 : Implement a circle class in C++ Each object of this class will represent a circle, storing its
radius and x and y co-ordinates of its centre as floats. Include a default constructor, access functions, an
area () function on and a circumference () function. The program must print the co-ordinates with
radius, area and circumference of the circle.

b) Enter the program and verify proper execution on the same Computer.

c) Obtain a hardcopy o the program listing as well as output.


Program : 8

a) Write a program in C++ using virtual function. The program must declare p to be a pointer to
objects of the base class person First, the program must assign p to point an instance x (name of
the person e.g. “BOB”) of class person. The program must then assign p to point at an instance y
(name of student, e.g. “TOM”) of the derived class student. Define a print () function in the base
class such that it invokes the same base class function to print the name of the name of the
student.

b) Enter the program and verify proper execution on the same Computer.

c) Obtain a hardcopy o the program listing as well as output.


program 9 :

Create a simple HTML page on the following topics: College profile, Computer Manufacturer, or
Software Development Company The page must consist of at least 3 paragraphs of text. The
page must have an appropriate title, background color or background image, and hyperlink to
other pages. The paragraphs must have text consisting of different colors and styles in terms of
alignment and Font Size.

b) Save the file and view the same using any HTML Browser. Verify functioning of the hyperlink. c)
Obtain a hardcopy of the HTML code only.
Experiment No. 10
a) Create a simple HTML page on the following topics: College profile,
Computer Manufacturer, or Software Development Company The page
must consist of a scrolling marquee displaying an appropriate Message.
The page must include a table with at last 5 rows and 3 columns having
merged cells at least at 1 place. The page must also display an image, an
image such that when the same is viewed through a browser and the
mouse is placed (hovered) on the image, an appropriate text message
should be displayed. The image itself should also act as a hyperlink to
another page.
b) Save the file and view the same using any HTML Browser offline. Verify
functioning of the hyperlinks.
c) Obtain a hardcopy of the HTML code only
Experiment No. 11
a) Write a program in Visual Basic that calculates area and selections of
two shapes, Circle and Rectangle.
b) Enter the program and proper execution of the same on the
computer.
c) Obtain a hard copy of the program listing by printing the FRM file
Experiment No. 12
a) Create a graphic editor using Visual Basic which has the following functions: change color
line width, fill color, change border color etc. (Select any three properties to change).
b) Enter the program and proper execution of the same on the computer.
c) Obtain a hard copy of the program listing by printing the FRM file.

You might also like