calculate and display the area and volume of the room. program to illustrate the working of objects and class in C++ programming
Write a function even_int that consumes an integer and produces "Even" if it is even and
"Odd" otherwise. You should use if and else for the two cases.
Implement F= "\\sum" (1,3,5,15) using
A. 8x1 MUX
B. 4x1 MUX
C. 2x1 MUX
Write a function greeting that consumes a string of length at least three and produces "Hello"
if the first three characters are "Hi!" and produces "Bye" otherwise.
Write a function bigger that consumes two numbers and produces the maximum of the two numbers.
class Graph:
def __init__(self,vertices):
self.V= vertices self.graph = []
def addEdge(self,u,v,w):
self.graph.append([u,v,w])
def find(self, parent, i):
if parent[i] == i:
return i
return self.find(parent, parent[i])
def union(self, parent, rank, x, y):
xroot = self.find(parent, x)
yroot = self.find(parent, y)
if rank[xroot] < rank[yroot]:
parent[xroot] = yroot elif rank[xroot] > rank[yroot]:
parent[yroot] = xroot else :
parent[yroot] = xroot
rank[xroot] += 1
def KruskalMST(self):
result =[] i = 0
e = 0 self.graph = sorted(self.graph,key=lambda item: item[2])
parent = [] ;
rank = []
for node in range(self.V):
parent.append(node) rank.append(0)
while e < self.V -1 :
u,v,w = self.graph[i] i = i + 1
x = self.find(parent, u)
y = self.find(parent ,v)
if x != y:
e = e + 1
result.append([u,v,w]) self.union(parent, rank, x, y)
for u,v,weight in result:
print ("%d -- %d == %d" % (u,v,weight))
b- Find the complexity of your program?
c- Show the loop invariant?
1. Write overloaded constructors that take different arguments and calculates the area of shape as well as displays it.
PRINT-OPTIMAL-PARENS(s, i, j){
if (i=j) then
print “A”i else{
print “(”
PRINT-OPTIMAL-PARENS(s,i,s[i, j])
PRINT-OPTIMAL-PARENS(s, s[i, j] + 1, j)
print “)”} }
b- Find the complexity of your program?
c- Show that the parenthesization algorithm is loop invariant?
with 0% plagiarism Write a program in C++ that implements a library management system. Theprogram MUST use filing to manage library data. All the required methods mustbe implemented as member functions of the Book class. When program starts, itshould display following menu and ask the user to make a choice:
1. Press 1 to add a new book in the library
2. Press 2 to display list of books available in the library
3. Press 3 to search a book by its name
4. Press 4 to delete a book by its ID
5. Press 5 to issue a book to the user
6. Press 6 to exit
After user has made a choice
hint
Case: User pressed 1:Record following details from the user and save in the file. If the file already exists
then open the file for writing, otherwise create a new file.
● Book name ●book id● Author name ● Genre● Number of pages● Rating● Language● Issued to (User name)● Issue date
Given an array
myArray of numbers, write a JS program to perform the following steps and log the result.
Multiply each value with 9.
Subtract 20 from each value.
Multiply each value with 7.
Log the values of the resulting array separated by a space.
Input
The input will be a single line containing an array myArray
Output
The output should be a single line with values separated by a space
Constraints
Each value in the array must be a number
Sample Input
[ 12, 2, 2, 4, 1 ]
Sample Output
616 -14 -14 112 -77
"use strict";
process.stdin.resume();
process.stdin.on("data", (inputStdin) => {
inputString += inputStdin;
});
process.stdin.on("end", (_) => {
inputString = inputString.trim().split("\n").map((str) => str.trim());
main();
});
function readLine() {
return inputString[currentLine++];
}
function main() {
const myArray = JSON.parse(readLine());
/* Write your code here */
}