If you like to use the vector<int> ai(4) instead of int ai[],You will need to include <vector> for that. If you use vector, thenno 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 numbersRead 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 > xbool is_right_angle_triangle(int x, int y, int z)//int n1 = x*x ; int n2 = y*y; int n3 = z*zreturn (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 trianglesthat 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 trianglesthat 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. Write these functions: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.
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.
Unlock instant AI solutions
Tap the button
to generate a solution