If you like to use the
You will need to include <vector> for that. If you use vector, then
no need to pass the size to each function.
Write a C++ program that loops forever using while(true).
In every loop cycle:
Asks the user to enter 4 positive numbers
Read the the integers and store them in array int ai[4].
Write a function called void sort_iarray(int a[], int size)
and you can use any library sorting function or code inside it.
Sort the array in an ascending order using the function you wrote.
Wite a function void display_iarray(int a[], int size)
that displays the array to screen.
Display the array ai to screen using the function you wrote.
Write these two functions that can be used in the two after them:
bool is_triangle(int x, int y, int z)
return x + y > z && x + z > y && y + z > x
bool is_right_angle_triangle(int x, int y, int z)
//int n1 = x*x ; int n2 = y*y; int n3 = z*z
return (n1 == n2 + n3) || (n2 == n1 + n3) || (n3 == n1 + n2)
Write a function int num_of_triangles(int a[], int size)
the returns the number of possible triangles
that can be formed from the four numbers in a.
Make it specific for size = 4 only;
no need to make it for large size.
You can use is_triangle inside it if you want.
Write a function int num_of_right_angle_triangles(int a[], int size)
the returns the number of possible right angle triangles
that can be formed from from the four numbers in a.
Make it specific for size = 4 only;
no need to make it for large size.
You can use is_right_angle_triangle inside it if you want.
Call num_of_triangles(ai, 4) and write to screen the answer.
Call num_of_right_angle_triangles(ai, 4) and write to screen the answer.
bool is_natural_consecutive_sequence(int a[], int size);
bool is_even_consecutive_sequence(int a[], int size);
bool is_odd_consecutive_sequence(int a[], int size);
Call each of the three sequence functions and display results to screen.
At the end of the cycle, ask the user if they want to repeat.
Use the exact names of the variables and functions.
You must write all the functions and use them.
to generate a solution
a solution
- Given an array of integers of size 10. Write a C++ function that takes the array as a parameter and returns the numbers of elements in the array that are small. A number is called "small" if it is in the range 1..10 inclusive. int ele[10] = {12, 56, -18, 1, 6, 4, 92, 2, 34, 78};; Expected Output: 4arrow_forwardImagine that you are a biomedical engineer analyzing DNA sequences. You have numerical measurements from two different measurement sources, m1 and m2, both of which are arrays. Write a function named dna that takes these two arrays as inputs. It should return a character array string of nucleotides (represented by the letters A, C, G and T). For a given index, i, the nucleotide in the string is: - ‘A’ if m1(i) >= 0 and m2(i) >= 0 - ‘C’ if m1(i) < 0 and m2(i) >= 0 - ‘G’ if m1(i) >= 0 and m2(i) < 0 - ‘T’ if m1(i) < 0 and m2(i) < 0 code to call the function m1 = [-2 -3 2.5 0.3]; m2 = [1.1 2.1 -0.8 0.1]; sequecne = dna(m1,m2); function dna Please use MATLABarrow_forwardIn c++, please! Thank you! Write a void function SelectionSortDescendTrace() that takes an integer array and sorts the array into descending order. The function should use nested loops and output the array after each iteration of the outer loop, thus outputting the array N-1 times (where N is the size). Complete main() to read in a list of up to 10 positive integers (ending in -1) and then call the SelectionSortDescendTrace() function. If the input is: 20 10 30 40 -1 then the output is: 40 10 30 20 40 30 10 20 40 30 20 10 The following code is given: #include <iostream> using namespace std; // TODO: Write a void function SelectionSortDescendTrace() that takes// an integer array and the number of elements in the array as arguments,// and sorts the array into descending order.void SelectionSortDescendTrace(int numbers [], int numElements) { } int main() { int input, i = 0; int numElements = 0; int numbers [10]; // TODO: Read in a list of up to 10 positive…arrow_forward
- Write a function that verifies if a given number exists in an array of floats. The function is supposed to return the first position in where the number is encountered. If the given number does not exist, the function returns –1. Then write a complete program that asks the user to enter an array of 8 floats and calls the function. The prototype of the function should be like: int Search (floats a[ ], int n, float number); Example: Consider the following array of floats int x[8]={2.1, 5.0, 9.8, 4.4, 6.8, 12.88, 9.87, 4.56}; If the number to be searched is 5.4, the function returns –1 If the number to be searched is 9.8,the function returns 2 C++ language only.arrow_forwardin c++ 1. Write a function that takes a 1 Dimensional array and an integer n andreturns the number of times ‘n’ appears in the array. If ‘n’ does not appearin the array, return -1.2. Write a function that takes a 2 Dimensional array and returns the positionof the first row with an odd sum. Assume that the column size is fixed at 4.If no sum is odd, return -13. Write a class, “pie”, that has a number of slices (int slices) as a privateproperty. Construct the pie with a number of slices and remove a slice witha function. Tell the user how many slices are in the pie.arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education