Task:
Write a function that takes root by reference and creates mirror image of the given tree
node* mir(node* root)
Original tree:
Root=1
Root->right=3
Root->left=2
Root->left->left=4
Root->left->right=5
Root->left->right->left=6
Root->left->right->right=7
New tree:
Root=1
Root->right=2
Root->left=3
Root->right->right=4
Root->right->left=5
Root->right->left->right=6
Root->right->left->left=7
What is the output of the following code segment?
int i = 5, j = 6, k = 7, n = 3;
cout << i + j * k - kn << endl;
cout << in << endl;
Write a function that takes an array of integers as input and prints the second-maximum difference between any two elements from an array.
The Fibonacci sequence is constructed by adding the last two numbers of the sequence so far to get the next number in the sequence. The first and the second numbers of the sequence are defined as 0 and 1. We get:
0, 1, 1, 2, 3, 5, 8, 13, 21…
Write a function which takes input as a number:
If the given number is a Fibonacci number, print the number
If the given number is NOT a Fibonacci number, print the sum of all odd Fibonacci numbers less than the given number.
write a function that takes an array of integer as output as input and prints the second maximum difference between any two elements from an array
Instruction: Using conditional statements, looping and functions, write an INTERACTIVE PROGRAM on BODY SYSTEMS. Each student must have two questions about the BODY SYSTEM.
Sample Output
Select Body System:
Enter Number of Body System: 1
Output:
Questions For Respiratory System:
Enter Number of Question: 1
Output:
Question 1:
Sample Question 1
Answer 1:
Sample Answer 1
Write a program that asks the user to enter a distance in meters. The program will then present the following menu of selections:
1. Convert to kilometers
2. Convert to inches
3. Convert to feet
4. Quit the program
Here is an example session with the program, using console input. The user’s input is shown in bold.
Enter a distance in meters: 500 [enter]
1. Convert to kilometers
2. Convert to inches
3. Convert to feet
4. Quit the program
Enter your choice: 1 [enter]
500 meters is 0.5 kilometers.
1. Convert to kilometers
2. Convert to inches
3. Convert to feet
4. Quit the program
Enter your choice: 3 [enter]
500 meters is 1640.5 feet.
1. Convert to kilometers
2. Convert to inches
3. Convert to feet
4. Quit the program
Enter your choice: 4 [enter]
Bye!
A painting company has determined that for every 115 square feet of wall space, one gallon of paint and eight hours of labor will be required. The company charges P120.00 per hour for labor. Write a program that allows the user to enter the number of rooms to be painted and the price of the paint per gallon. It should also ask for the square feet of wall space in each room. The program should have functions that return the following data:
· The number of gallons of paint required
· The hours of labor required
· The cost of the paint
· The labor charges
· The total cost of the paint job
Then it should display the data on the screen.
A prime number is a number that is evenly divisible only by itself and 1. For example, the number 5 is prime because it can be evenly divided only by 1 and 5. The number 6, however, is not prime because it can be divided evenly by 1, 2, 3, and 6. Write a C++ program using a function that takes an integer as an argument and returns true if the argument is a prime number, or false otherwise. Demonstrate the function in a complete C++ program.
. Rewrite the following expressions using an if...else statement. (Assume that all variables are declared properly.)
a. (x < 5) ? y = 10 : y = 20;
b. (fuel >= 10) ? drive = 150 : drive = 30;
c. (booksBought >= 3) ? discount = 0.15 : discount = 0.0;