CS1 - Pract - Aim of Experiments
CS1 - Pract - Aim of Experiments
1) Aim: Write a function in C++ that exchanges data (passing by reference) using swap
function to interchange the given two numbers.
2) Aim: Write a program in C++ that first initializes an array of given 10 sorted real numbers.
The program must verify whether a given element belongs this array or not, using Binary –
Search technique. The element (to be searched) is to be entered at the time of execution. If the
number is found, the program should print its position in the array, otherwise it should print
“The number is not found.”
3) Aim: Write a program in C++ that first initializes an array of given 10 real numbers. The
program must sort numbers in ascending order using Bubble – Sort method. It should print the
given list of numbers as well as the sorted list.
4) Aim: Write a program in C++ to print the given string (including spaces) and reverse it
using a function, which locates the end of the string. Then swap the first character with the last
character, the second character with second last character and so on.
Theory: Explain the functions used in program [For example: gets( ) , puts( )].
5) Aim: 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 float. Include a default constructor,
access functions, an area( ) function and a circumference( ) function. The program must print
the co-ordinates with radius, area and circumference of the circle.
Theory: Explain the syntax of class and access specifiers (public, private, protected) in detail.
6) Aim: 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 reaches the end of its scope.
7) Aim: Write a program in C++ with a ratio class using member functions like assign( )
function to initialize its member data (integer numerator and denominator), convert( ) function
to convert the ratio into double, invert( ) function to get the inverse of the ratio and print( )
function to print the ratio and its reciprocal.
Theory: Explain the concept of constructor and operator used in the program.
9) Aim: 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 eg. “BOB”) of class Person. The program must then assign ‘p’
to point at an instance y (name of the student, eg.”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 person by default. The second call for the same should invoke the derived class
function to print the name of student.
10) Aim: 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 accept weightage (marks) in sports and Class Result to calculate the total marks. The
program must print the roll number, individual marks obtain in two subjects, Sports and total
marks.
Student
Test Sports
Result
11) Aim: Write a program in C++ to read the name of a country from one text file and name of
its corresponding capital city from another text file. The program must display the country
name and indicate its corresponding capital (for at least five countries) in the output.
12) Aim: Create a simple HTML page for 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.