Write a C++ program that creates two one dimensional arrays “A” and “B” of size 20 elements each. The main
program should get the input in the array “A” from the user and initialize array “B” with values “0”. Your
program should calculate the (number -2) of each element of array “A” and should store in the square value
in corresponding positions (index) in the array “B”. In the end, the main program (main function) prints the
calculated values of array “B”. Also display the values in array B which are Odd (if any).
The principal of a school wants to speak with some of the students to assess their over all development including studies,most of the teachers were selecting the toppers of their classes but Mr,sam thought of an idea to select the bunch of students who did not have much difference in their marks so that he gains the reputation of a teacher who teaches well to the whole class and not just to a bunch of brilliant students.
Your are required to help mr,sam in selecting K students that can speak with principle from his class .you need to return an integer array representing the marks of the selected students sorted in ascending order.
I/p1:An integer value denoting the number of students in Mr.sam’s class.
I/p2:An integer array of size input1representing the marks of each student
I/p3:An integer K denoting the number of representatives to be
O/p:return an integer array containing the marks of K selected students sorted in ascending order.
Ex:
I/p1:10
I/p2:{950,477,55,602,881,302,859,438,551,382}
I/p3:1
O/pt:{950}
Harrypotter is visiting his uncle’s house ,the house of Black ,and ants to know more about the family through their ancestral tree.He notices that the ancestraltreebegins with the head of the family at the top,having 2 children as his descendants,This pattern is followed throught and each member is represented by unique integer.
Given relationships in the form ofan integer arraywhere the head of the family is at the first position (i=0) and his children areat position (2*i+1) and (2*i+2).
Your task is to help harry find and return all the siblings of any given family member and return them in the form of a sorted array.
Note:if there are no siblings ,return {-1}.
Example:
Input1:5
Input2:{1,2,3,4,5}
Input3:1
Output:{-1}
you want to buy a particular stock at its lowest price and sell it later at its highest price,since the stock market is unpredictable,you steal the price plans of a company for this stock for the next N days.
Find the best price you can get to buy this stock to achieve maximum profit.
Note:The initial price of the stock is 0.
Input1:Nnumber of days.
Input2:Array representing changing stock price for the day.
Output: Your function must return the best price to buy the stock at.
Example:
Input1:5
Input2:{-39957,-17136,35466,21820,-26711}
Output:-57093
a java program that will compute the surface area and volume of a cube using class
(FOR C #) A class called Company is to be defined as illustrated in the class diagram. It contains two data members: name (of type string) and salary (of type int); and three member functions: getName(), getSalary (), and getEmployee().
Three instances of Company called s1, s2, and s3 shall then be constructed with their respective data members, as shown in the instance diagrams.
Company
-name:string=”Cube”
-salary:int=470000000
+Company()
+Company(n:string)
+Company(n:string, s:int)
+getName():string
+getSalary():int
+getEmployee():int
S3 - Contractor
-name:string=”Jake”
-salary:int=1800
+ getName()
+ getSalary ()
+ getEmployee()
Objects
S1 - Employee
-name:string=”Mark”
-salary:int=1900
+ getName()
+ getSalary ()
+ getEmployee()
S2 - Manager
-name:string=”Kai”
-salary:int=1700
+ getName()
+ getSalary ()
+ getEmployee()
Write a program with structure Inventory(name, colour, size, cost). Then create 3 objects and write code to print information about Inventory with the highest cost. (FOR C #)
Write a java program to find the sum of all odd numbers between 1 to n - using do...while loop
The following code is supposed to display the positive even numbers less than 12. That is, it will output the numbers 2, 4, 6, 8 and 10. However, there is a logical error in the code. Explain what the output of the code below will be. Then write a small program including the code below and make the necessary changes to fix the code so that it displays what it is intended to display. Ensure that your program works correctly. Only submit the program, not the output.
5.1. [15 marks] Write a method with the following details:
5.2. [10 marks] Using the method below, write the code statements to call this method ten times with angle values of 0.500, 0.501, 0.502, 0.503, ... 0.509 and printout the values for the angle, resulting sine and cosine in a tabular format. Use a “for” looping structure.