Write a program which has a class named binary which has a character array to store a binary
string. The class decimal derives from class binary and contains an integer data member. Another
class called octal also derives from binary. Each class should contain constructors and appropriate
data members to input and display the elements. The display function of binary class displays the
binary equivalent, octal class’s display function displays octal equivalent whereas decimal class’s
display function displays the decimal equivalent.
Area of Largest Rectangle in Histogram
Given an list of integer
heights representing the histogram's bar height where the width of each bar is 1, return the area of the largest rectangle in the histogram.
Input
The input will be a single line containing space-separated integers, denoting the heights of the bars.
Output
The output should be a single line containing the area of the largest rectangle in the rectangle.
Explanation
For example, if the given list of numbers are
2 1 5 6 2 3 , when they are drawn adjacent to each other according to their heights, the histogram will be like
The largest rectangle can be found in between 5 and 6, which is 10.
Sample Input 1
2 1 5 6 2 3
Sample Output 1
10
Sample Input 2
65 87 96 31 32 86 57 69 20 42
Sample Output 2
248Palindrome Pairs
Given a list of unique words, write a program to print all the pairs of the distinct indices (i, j) in the given list, so that the concatenation of two words at indices i and j is a palindrome.
Input
The input will be a single line containing a sentence.
Output
The output should be printing each distinct pair of indices (i, j) each in a line in ascending order.
If there are no distinct pairs found, print "-1"
Note: Consider (i, j) and (j, i) as two different pairs.
Explanation
For example, if the given sentence is
was it a car or a cat I saw
The words that can be concatenated to make a palindrome are
Words Indices
(was, saw) (0, 8)
(a, a) (2, 5)
(a, a) (5, 2)
(saw, was) (8, 0)
So the output should be
0 8
2 5
5 2
8 0
Sample Input 1
was it a car or a cat I saw
Sample Output 1
0 8
2 5
5 2
8 0
Sample Input 2
bat tac tab cat
Sample Output 2
0 2
1 3
2 0
3 1Write a program that reads a number and prints all of its binary digits: Print the remainder
number % 2, then replace the number with number / 2. Keep going until the number is 0. For
example, if the user provides the input 13, the output should be
1
1
1
Write a function named "reduce" that takes two positive integer arguments, call the "number" and "denim" treats them as the numerator and denominator of a fraction and reduce the fraction.that is to say each of the two arguments will be modified by dividing it by the greatest common division of two integers
Get TWO (2) employee information from the user including their names, employee IDs (e.g: EM001), and working hours. Assume they are paid RM255 per hour, display the employee’s information with the highest salary. Salary is calculated based on rate per hour multiply by working hours. Using selection.
Secret Message - 1
Given a string, write a program to mirror characters of string in alphabetical order to create a secret message.
a b c d e f g h i j k l m
z y x w v u t s r q p o n
n o p q r s t u v w x y z
m l k j i h g f e d c b a
Input
Input will be a string in the single line containing spaces and letters both uppercase and lowercase.
Output
Output should be a single line containing secret message. All characters in the output should be in lower case.
Explanation
For example, if given input is "python", "p" should replaced with "k", similarly "y" with "b", "t" with "g", "h" with "s", "o" with "l", "n" with "m". So output be "kbgslm".
Sample Input 1
python
Sample Output 1
kbgslm
Sample Input 2
Foundations
Sample Output 2
ulfmwzgrlmh
Let we have to prepare the final result of each student for a particular subject. The final
marks are sum of marks obtained by the student in T1, T2, T3, P1, P2, and attendance in theory class. Let
there are following classes:(a) Faculty: which have no data member but have a member function to assign the marks of T1,
T2, T3, P1, P2, and percentage of attendance to each student.
(b) Administration: which have no data member but have member functions to enter the name
and roll number of each student, and to calculate the total marks and final grade of each student.
Grade ‘A’ for> 80% marks, ‘B’ for 70 to 80%, ‘C’ for 60 to 70%, D for 50 to 60%, F for <50%.
Make a MATLAB function which count on all the prime numbers from 0-1000.
• Sort the numbers in descending order.
• Sum all the even numbers in ascending order from 0-100.
• Use only While loop.
Make a class Arithmetic. two constructer first constructer two number add and sabtruct.second constructer two number multiply and divided.