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.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

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, 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.

 
 
 
 
 
 
 
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.
AI-Generated Solution
AI-generated content may present inaccurate or offensive content that does not represent bartleby’s views.
steps

Unlock instant AI solutions

Tap the button
to generate a solution

Knowledge Booster
Array
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education