Professional Documents
Culture Documents
AP ASWIN Dreasearch Analysis Using MML or Organic
AP ASWIN Dreasearch Analysis Using MML or Organic
Aim:
Write a C++ program that accepts a character and print the ASCII value of the same character as output.
Algorithm:
Code:
Output:
Result:
Thus a program in C++ to find the ASCII value of the character has been studies and executed successfully.
PROGRAM-2
Aim:
Write a C++ program to declare char, short, int, unsigned int, unsigned long, float, double, long double
datatype variables and then print the storage space reserved for those variables. (Various built-in data types).
Algorithm:
Output:
Result:
Thus a program in C++ to find the storage space for the datatypes has been studied and executed
successfully.
Program:3
Aim:
To write a C++ program that inputs five numbers and calculate the sum and average of entered number using
float array.
Algorithm:
Output:
Result:
Thus the program in C++ to calculate the sum and average of the numbers has been studied and executed
successfully.
PROGRAM-4
AIM:
Declare a struct storing the following information related to students: student_name, roll_num, marks. Create a
struct object and store the values of the object by taking input from the user. Add a function that displays the
struct object values. (struct, function)
ALGORITHM:
code:
Output:
RESULT:
Thus a program in C++ to input the students name ,roll no and marks has been studied and executed
successfully.
PROGRAM-5
AIM:
Write a C++ program create the student class with the following data members: student_name, roll_num,
marks1, marks2. Take name, roll number, marks1 and marks2 information from user. Calculate the mean
value of marks and display student_name, roll_num, mean mark values.
ALGORITHM:
❖ Start the program.
❖ Create a class called "student."
❖ Declare the private data members: student name (string), roll num (integer), marks1 (integer), and marks2
(integer).
❖ Define the public member functions "get" and "put" to handle input and output operations.
❖ Inside the "get" function, display a prompt to enter the student's details.
❖ Accept input for student name, roll num, marks1, and marks2 from the user using cin.
❖ Inside the "put" function and calculate the mean of marks (mean = (marks1 + marks2) / 2).
❖ Display the student's name, roll number, and mean marks on the console using cout.
❖ Create an object "s" of the "student" class.
❖ Call the "get" function on the "s" object to get the student's details from the user.
❖ Call the "put" function on the "s" object to display the student's information and mean marks.
❖ End the program.
CODE:
OUTPUT:
RESULT:
Thus a program in C++ to input the details of the student and to find the mean value of the marks has be
studied and executed successfully.
LAB-2
PROGRAM-1
AIM:
To create a class workers mentioning their id, name and department to which the
belong. Compute their weekly wages for the number of hours they work, fixing a
nominal pay rate which is a sensitive data. Include the Accessor and mutator member
functions to set and display the wages.
ALGORITHM:
1. Create a class named "Worker" with private member variables for id,
name,department, nominalPayRate, and weeklyWages.
2. Define a constructor for the "Worker" class that takes workerId,
workerName,workerDept, and payRate as parameters and initializes
the corresponding member variables.
3. Define a public member function "getWeeklyWages()" that returns the
value ofthe "weeklyWages" member variable.
4. Define a public member function "setWeeklyWages(double
hoursWorked)" thattakes the number of hours worked as a parameter.
5. Inside the "setWeeklyWages()" function: a. Calculate the weekly wages
by multiplying the nominal pay rate with the hours worked and store
the result inthe "weeklyWages" member variable.
6. Define a public member function "displayDetails()" that displays the
worker's ID,name, department, and weekly wages.
7. In the "main" function Create a "Worker" object.
8. Run the program.
CODE:
OUTPUT:
RESULT:
The above given program executes correctly and the details of the worker are given asoutput
correctly.
PROGRAM-2
AIM:
Write a C++ program that uses an area () function for the calculation of area of a triangle
or a rectangle or a square. Number of sides ( 3 for a triangle, 2 for a rectangleand 1 for a square)
suggest about the shape for which area is to be calculated. [ Function Overloading ]
ALGORITHM:
1. Include necessary header files
OUTPUT:
RESULT:
The above program has executed correctly and output is given correctly of any of the
given 3 shapes
PROGRAM-3
AIM:
To create a class named 'complex' with two data members- real and imag and afunction to
display the value which is in the form of 'a+ib'.
The class has three constructors which are :
1 - having no parameter - values of both real and imag are assigned zero.
2 - having two numbers as
parameters
3 - Copy constructor
4 – Function to add two complex numbers
ALGORITHM:
1. The code defines a class named `Complex` to represent complex numbers with private
member variables `real` and `imag` of type `int`.
3. The class has a member function `display` that outputs the complex number in the format
`real + imagi` with the correct sign for the imaginary part.
4. The class also has a member function `add` that takes a constant reference to another
`Complex` object (`other`) as a parameter. It returns a new `Complex` object representing the
sum of the current complex number and the `other` complex number.
RESULT:
The above program executes perfectly and the output is shown correctly.
PROGRAM-4
AIM:
To create a class 'Student' with three data members which are name, age and address. The
constructor of the class assigns default values to name as "unknown", age as '0' and address
as "not available". It has two functions with the same name 'setInfo'. First function has two
parameters for name and age and assigns the same whereas the second function takes has
three parameters which are assigned to name, age and address respectively. Print the name,
age and address of 10 students.
ALGORITHM:
1. The code defines a class named `Student` with private member variables `name`, `age`, and
`address`, and public member functions to set and display student information.
2. The `Student` class has a default constructor that initializes the member variables with
defaultvalues: "unknown" for name, 0 for age, and "not available" for address.
4. The class also has a `displayInfo` member function that outputs the student's name, age,
andaddress using the stored member variables.
CODE:
OUTPUT:
RESULT:
The above program executes correctly and shows the address of the studentscorrectly as
given in the program as output perfectly.
PROGRAM-5
AIM:
To write a program in C++ to print the product of two numbers using friend function.
ALGORITHM:
1. The code defines a class named `Multiplication` with a private member variable `number`
oftype `int`.
2. The `Multiplication` class has a constructor that takes an integer parameter and initializes
the `number` member variable with the provided value.
3. There is a friend function `multiply` defined outside the class that takes two constant
references to `Multiplication` objects as parameters and returns the product of their
`number`values.
4. In the `main` function, the user is prompted to enter two numbers, which are stored in
integer variables `num1` and `num2`.
5. The `multiply` function is then called with `num1` and `num2` as arguments, and the
productis stored in the integer variable `product`.
6. Finally, the calculated product is displayed to the user using a formatted message.
CODE:
OUTPUT:
RESULT:
The above program gives the output of the 2 numbers multiplication correctly as perthe
given inputs.
LAB-3
PROGRAM-1
AIM:
Create a class called Distance with private members feet and inches.
• Use parameterized constructor to read the value of feet and inches.
• use member function display() to display the read value.
• Use operator fn + to add two distances using friend function.
ALGORITHM:
CODE:
OUTPUT:
RESULT:
In the above program we created a class called distance with private members
feet and inches. And the program ran successfully and the output was shown.
PROGRAM-2
AIM:
Get two strings. Check whether entered strings are equal using
operator overloading using member function.
ALGORITHM:
CODE:
OUTPUT:
RESULT:
In the above program we gave 2 string and input and checked whether the 2
strings are equal or not using operator overloading, the program ran successfully
and the required output was shown.
PROGRAM-3
AIM:
Create a class Box having length, breadth and height as private data
members and count as static data member.
• The class uses a constant member function getvolume() to return the
product of length, breadth and height.
• The class uses static member function to return the count.
ALGORITHM:
1. Define a class Box with private properties length, breadth, and height.
2. Include a private static property count to keep track of the number of
instances created.
3. Implement a constructor to initialize dimensions and increment count.
4. Create a method getVolume() to calculate and return the volume of the
box.
5. Define a static method getCount() to retrieve the total count of boxes.
6. Initialize the static member variable count to 0 outside the class
definition.
7. Inside the main function:
• Create two instances of Box with specified dimensions.
• Calculate and display the volume of each box using the getVolume()
method.
Print the total count of boxes using the getCount() method
CODE:
OUTPUT:
RESULT:
In the above program we Created a class Box having length, breadth and height
as private data members and count as static data member, the program ran
successfully and the output was shown.
LAB-4
PROGRAM-1
AIM:
Create a class named Vehicle with two data member named mileage and price.
Create its subclass Car with datamembers to store ownership cost, warranty
(by years), seating capacity and fuel type (diesel or petrol). store and print the
information of a car (ownership cost, warranty, seating capacity, fuel type,
mileage, and price)
ALGORITHM:
• Create a class called vehicle with two member variables: mileage
and price.
• Implement a member function display() inside the vehicle class.
This function prompts the user to enter the details of the vehicle
(mileage and price) and stores the values in the respective member
variables.
• Create a class called car that inherits from the vehicle class.
• Inside the car class, add four additional member variables:
ownership_cost, warranty, seating_type, and fuel_type.
• Implement a member function show() inside the car class. This
function prompts the user to enter the details of the car(ownership
cost, warranty, seating type, and fuel type) and stores the values in
the respective member variables.
• In the main() function:
• Create an object c of the car class.
• Call the display() function on the c object to prompt the userfor the
vehicle details and store them in the mileage and price member
variables inherited from the vehicle class.
• Call the show() function on the c object to prompt the user for the
car details and store them in the ownership_cost, warranty,
seating_type, and fuel_type member variables defined in the car
class.
• Return 0 to indicate successful execution.
CODE:
OUTPUT:
RESULT:
The above program successfully stored and printed the details ofvehicle.
PROGRAM-2
AIM:
ALGORITHM:
a) Start the program.
b) Prompt the user to enter the number of students in the class.
c) Create arrays of objects of the Physics, Chemistry, and Mathematics
classes, with the size equal to the number of students entered by the
user.
d) Start a loop to get data for each student:
a. Get the name of the student using the getData() function of
the Physics class.
b. Generate the roll number for the student using the
generateRollNumber() function of the Physics class.
c. Get the marks in Physics for the student using the
getPhysicsMarks() function of the Physics class.
d. Get the name of the student using the getData() function of
the Chemistry class.
e. Generate the roll number for the student using the
generateRollNumber() function of the Chemistry class.
f. Get the marks in Chemistry for the student using the
getChemistryMarks() function of the Chemistry class.
g. Get the name of the student using the getData() function of
the Mathematics class.
h. Generate the roll number for the student using the
generateRollNumber() function of the Mathematics class.
i. Get the marks in Mathematics for the student using the
getMathMarks() function of the Mathematics class.
CODE:
OUTPUT:
RESULT:
The above program has calculated the total, average of the class andare
displayed to the console as output
PROGRAM-3
AIM:
Create a class named Shape with a function that prints "This is a shape". Create
another class named Polygon inheritingthe Shape class with the same function
that prints "Polygon is a shape". Create two other classes named Rectangle
and Trianglehaving the same function which prints "Rectangle is a polygon"
and "Triangle is a polygon" respectively. Again, make another class named
Square having the same function which prints "Square is a rectangle".
ALGORITHM:
• Start the program.
• Create a class named `Shape`.
o Declare a function named `printInfo()` within the
`Shape` class that prints "This is a shape".
• Create a class named `Polygon` inheriting from the `Shape`class.
o Declare a function named `printInfo()` within the
`Polygon` class that prints "Polygon is a shape".
• Create a class named `Rectangle` inheriting from the
`Polygon` class.
o Declare a function named `printInfo()` within the
`Rectangle` class that prints "Rectangle is a polygon".
• Create a class named `Triangle` inheriting from the
`Polygon` class.
o Declare a function named `printInfo()` within the
`Triangle` class that prints "Triangle is a polygon".
• Create a class named `Square` inheriting from the
`Rectangle` class.
o Declare a function named `printInfo()` within the
`Square` class that prints "Square is a rectangle".
• Start the `main()` function.
• Create an object `shape` of the `Shape` class.
• Create an object `polygon` of the `Polygon` class.
• Create an object `rectangle` of the `Rectangle` class.
• Create an object `triangle` of the `Triangle` class.
• Create an object `square` of the `Square` class.
• Call the `printInfo()` function for the `shape` object.
• Call the `printInfo()` function for the `polygon` object.
• Call the `printInfo()` function for the `rectangle` object.
• Call the `printInfo()` function for the `triangle` object.
• Call the `printInfo()` function for the `square` object.
• End the `main()` function.
• End the program.
CODE:
OUTPUT:
RESULT:
The above program has successfully overrided the method in base classand
also the function was overloaded.
LAB-5
PROGRAM-1
AIM:
OUTPUT:
RESULT:
By above code Write a C++ program to print the address and value ofthe
variable
PROGRAM-6
AIM:
OUTPUT:
RESULT:
The above code is to find the smallest of three numbers usingpointers.
PROGRAM-3
AIM:
OUTPUT:
RESULT:
By the above code we can print the given word into uppercase tolowercase
and vice versa.
PROGRAM-4
AIM:
ALGORITHM:
CODE:
OUTPUT:
RESULT:
By the above code we can print a number and name (Entered usingKeyboard) using this
pointer.
PROGRAM-5
AIM:
ALGORITHM:
• Define a constant integer 'size' to specify the size of the array (e.g., 5).
• Create an integer array 'arr' with 'size' elements and initialize it with some values.
• Create an integer pointer 'ptr' and point it to the first element of the array 'arr'.
• Print the message "Elements of the array:".
• Use a loop to iterate from 0 to 'size-1':
o Inside the loop:
• Print the message "Element i: " followed by the value pointed to by 'ptr' (*ptr).
• ii. Move the pointer 'ptr' to the next element in the array.
• End the loop.
CODE:
OUTPUT:
RESULT:
PROGRAM-6
AIM:
Write a function which will take pointer and display the number onscreen.
Take number from user and print it on screen using that function. ( Pointer to
Function)
ALGORITHM:
• Define a function displayNumber that takes an integer pointer ptr as an argument:
o Print the message "Number: " followed by the value pointed to by ptr (*ptr).
• In the main function:
• Declare an integer variable number.
• Print the message "Enter a number: ".
• Read and store the input in the variable number.
• Call the function displayNumber with the address of number (&number) as an
argument.
CODE:
OUTPUT:
RESULT:
By the above code we can Write a function which will take pointer and display
the number on screen. Take number from user and printit on screen using that
function.
LAB-6
PROGRAM-1
AIM:
Write a function template to find the average elements of an array. Pass the
entire array and its size as an argument to a function.
CODE:
OUTPUT:
RESULT:
OUTPUT:
RESULT:
Hence the above code we can write a function template to sort the elements
using bubble sort.
PROGRAM-3
AIM:
RESULT:
Hence the above program has been studies and executed successfully
PROGRAM-4
AIM:
You are given integers. Sort the integers and print the sorted order.Store
the integers in a vector. Vectors are sequence containers representing
arrays that can change in size.
OUTPUT:
RESULT:
PROGRAM-6
AIM:
OUTPUT:
RESULT:
by the above code we can write an STL program to reverse the elements of
linked list.
LAB-7
PYTHON
PROGRAM-1
AIM:
CODE:
OUTPUT:
RESULT:
PROGRAM-2
AIM:
To compute the area of a right angled triangle with nonhypothesis sides a and b.
CODE:
OUTPUT:
RESULT:
PROGRAM-3
AIM:
CODE:
OUTPUT:
RESULT:
By the above code we can print the print value of x for the givenprogram where x
= -10
PROGRAM-4
AIM:
To input a number and find the sum of digit using while loop.
CODE:
OUTPUT:
RESULT:
By the above code we can input a number and find the sum ofdigit using
while loop
PROGRAM-5
AIM:
To generate calendar of a month given the start day and number of days
CODE:
OUTPUT:
RESULT:
PROGRAM-6
AIM:
OUTPUT:
RESULT:
By the above code we can find LCM of two numbers using dowhile loop
in python
PROGRAM-7
AIM:
RESULT:
By the above code we can write a python program using if elseelse if for
given scenario.
SWITCH CASE:
AIM:
OUTPUT:
RESULT:
By the above code we can write python code to execute thesame scenario using
switch case
LAB-8
PROGRAM-1
AIM:
OUTPUT:
RESULT:
PROGRAM-2
AIM:
OUTPUT:
RESULT:
By the above code we can Remove all special characters otherthan digits and
characters
PROGRAM-3
AIM:
OUTPUT:
RESULT:
PROGRAM-4
AIM:
OUTPUT:
RESULT:
By the above code we can Get the first two and last twocharacters of a string
PROGRAM-5
AIM:
RESULT:
OUTPUT:
RESULT:
Aim :
Code :
Output :
Result :
By the above code we can Merge two dictionaries.
PROGRAM-1
Aim :
Combine two dictionaries by adding values for commonkeys.
Code :
Output :
Result :
By the above code we can Combine two dictionaries by addingvalues for
common keys.
PROGRAM-2
Aim :
Create a list from a tuple and vice versa.
Code :
Output :
Result :
By the above code we can Create a list from a tuple and viceversa.
PROGRAM-3
Aim :
Calculate the bill based on a dictionary of productspurchased and their
MRPs.
Code :
Output :
Result :
By the above code we can Calculate the bill based on adictionary of
products purchased and their MRPs.
PROGRAM-4
Aim :
Find the maximum and minimum values in adictionary
Code :
Output :
Result : By the above code we can Find the maximum and minimumvalues in a
dictionary
PROGRAM-5
Aim :
Print "Hello World" with the first letter capitalized.
Code :
Output :
Result :
By the above code we can Print "Hello World" with the firstletter
capitalized.
PROGRAM-6
Aim :
Toggle the case of characters in a string
Code :
Output :
Result :
By the above code we can Toggle the case of characters in astring.
PROGRAM-7
Aim :
Print "Hello Friends" by replacing "world".
Code :
Output :
Result :
By the above code we can Print "Hello Friends" by replacing"world".
PROGRAM-8
Aim :
Encrypt a message by adding a key value to everycharacter.
Code :
Output :
Result :
By the above code we can Encrypt a message by adding a keyvalue to
every character.
Lab 9
PROGRAM-1
Aim :
Program to find the product of two integers using afunction
Code :
Output :
Result :
By the above code we can Program to find the product of twointegers
using a function.
PROGRAM-2
Aim :
Program to swap two strings using a function.Code :
Output :
Result :
By the above code we can Program to swap two strings using afunction.
PROGRAM-3
Aim :
Program to find perfect numbers between 1 and 1000using a function.
Code :
Output :
Result :
By the above code we can Program to find perfect numbersbetween 1
and 1000 using a function.
PROGRAM-4
Aim :
Program to find the length of the string "refrigerator"without using len
function.
Code :
Output :
Result :
By the above code we can Program to find the length of thestring
"refrigerator" without using len function.
PROGRAM-5
Aim :
Program to create a new string with consonants deletedfrom "Hello, have a
good day".
Code :
Output :
Result :
By the above code we can create a new string with consonantsdeleted
from "Hello, have a good day".
PROGRAM-6
Aim :
Program to find the sum of all even numbers in a set usinga function.
Code :
Output :
Result :
By the above code we can find the sum of all even numbers in aset using a
function.
PROGRAM-7
Aim :
Program to split a list of 10 elements into two differentlists.
Code :
Output :
Result :
By the above code we can split a list of 10 elements into twodifferent
lists.
PROGRAM-8
Aim :
Program to calculate factorials and store them in adictionary.
Code :
Output :
Result :
By the above code we can Program to calculate factorials andstore them
in a dictionary.
PROGRAM-9
Aim :
Program to count occurrences of each letter in the word
"MISSISSIPPI" using a function and store them in a dictionary
Code :
Output :
Result:
By the above code we can count occurrences of each letter inthe word
"MISSISSIPPI" using a function and store them in a dictionary.
PROGRAM-10
Aim :
Program to create a tuple from user-given eveninteger inputs and
print them as a list
Code :
Output :
Result:
By the above code we can Program to create a tuple from user-given even
integer inputs and print them as a list.
PROGRAM-11
Aim :
Program to calculate exp(x, y) using recursivefunctions.
Code :
Output :
Result:
By the above code we can calculate exp(x, y) using recursivefunctions.
PROGRAM-12
Aim :
Program to implement the Tower of Hanoi problemusing a recursive
function.
Code :
Output :
Result:
By the above code we can implement the Tower of Hanoiproblem using
a recursive function.
Lab 10
PROGRAM-1
Aim :
Write a program that has class Cars. Create two objectsand set Car1to be a red
convertible with price 10 lakhs and name Pugo.Car2to be a blue sedan named
Mavoworth 6
Lakh
Code
:
Output :
Result:
By the above code we can Write a program that has class Cars.Create two
objects and set Car1to be a red convertible with price 10 lakhs and name
Pugo.Car2to be a blue sedan named Mavoworth 6 lakhs
PROGRAM-2
Aim :
Write a program to compare length of 2 strings using
_cmp_ function.
Code :
Output :
Result:
By the above code we can Write a program to compare lengthof 2 strings
using _cmp_ function.
PROGRAM-3
Aim :
Make a class triangle. Enter its three sides andcalculate its area.
Code :
Output :
Result:
By the above code we can Make a class triangle. Enter its threesides and
calculate its area.
PROGRAM-4
Aim :
Write a program that uses a class attribute to define some default titles for
faculty in a college. Display the namealong with title and department of the
college.
Code :
Output :
Result:
By the above code we can Write a program that uses a class attribute to
define some default titles for faculty in a college.
Display the name along with title and department of thecollege.
PROGRAM-5
Aim :
Write a program that has a class pointwith attributes asthe X and Y co-
ordinates. Make two objects of this class and find the midpoint of both the points
Code :
Output :
Result:
By the above code we can Write a program that has a class pointwith
attributes as the X and Y co-ordinates. Make two objects of this class
and find the midpoint of both the points
PROGRAM-6
Aim :
Write a program to deposit or withdraw money in abank account.
Code :
Output :
Result:
By the above code we can Write a program to deposit orwithdraw
money in a bank account.
Lab 11
PROGRAM-1
Aim :
Write a program for a publishing company that markets books
and CDs. Write a class Publication that stores title and price. Derive a
class Book which hasan additional member as number of pages. Derive
another class Lecture from Publication with additionalmember play time.
Create objects and display outputs accordingly
Code :
Output :
Result:
By the above code we can Write a program for a publishing
company that markets books and CDs. Write a class Publicationthat stores
title and price. Derive a class Book which has
an additional member as number of pages. Derive anotherclass
Lecture from Publication with additional member play time. Create
objects and display outputs accordingly
PROGRAM-2
Aim :
MULTIPLE.Define a class student with data membersas ID
number and name. Define a class Grade that has data member
CGPA. Derive a class scholarship which is derived from both
these classes to compute scholarship as follows: Rs.10,000/-pm
if CGPA>9. Rs.7500/-pm
ifCGPA>8. Rs.5000/-pm if CGPA>7.5.
Create an object of scholarship and display. in python
Code :
Output :
Result:
By the above code we can Define a class student with data
members as ID number and name. Define a class Grade that has data
member CGPA. Derive a class scholarship which isderived from
both these classes to compute scholarship asfollows: Rs.10,000/-pm
if CGPA>9. Rs.7500/-pm ifCGPA>8.
Rs.5000/-pm if CGPA>7.5. Create an object of scholarship and
display. in python
PROGRAM-3
Aim :
Inheritance”. Define a class which has two objects ofanother class. Create a
class Point with members as x, y
coordinates. Create another class Location that has objects
source and destination of class Point. Computethe distance
between these locations and print the distance in python
Code :
Output :
Result:
By the above code we can Define a class which has two objectsof
another class. Create a class Point with members as x, y
coordinates. Create another class Location that has objectssource and
destination of class Point. Compute the distancebetween these locations
and print the distance in python
PROGRAM-4
Aim :
MULTI-PATH. Create a base class Familywith
member surname. Create a derived class 1 Fatherwith father name
and occupation. Create another derived class2 Motherwith mother
name and age. Create a Derivedclass 3 childfrom Fatherand
Motherwith additional
member of child name. Create an object of child andprintthe
details of the family members in python with output
Code :
Output :
Result:
By the above code we can Create a base class Familywith
member surname. Create a derived class 1 Fatherwith fathername and
occupation. Create another derived class 2
Motherwith mother name and age. Create a Derived class3
childfrom Fatherand Motherwith additional member of
child name. Create an object of child and printthe details ofthe family
members in python with output
PROGRAM-5
Aim :
Write a program that has an Abstract class Polygon. Derive Threeclasses
Rectangle, Square and
Triangle from Polygon. Write methods to get the details oftheir
dimensions and then calculate the surface area. in python
Code :
Output :
Result:
By the above code we can Write a program that has an
Abstract class Polygon. Derive Threeclasses Rectangle, Squareand
Triangle from Polygon. Write methods to get the details of their
dimensions and then calculate the surface area. i