Write a C++ program that reads in a list of integers, separated by a space, into an array of size N. The last number is -1 but should not be added to the array. The number of integers will be < N. Then output only those numbers, one per line, that are prime, perfect, the sum of a prime or perfect number, or a member of the well-known Fibonacci sequence.
PLEASE GIVE IT A THUMBS UP

#include <iostream>
using namespace std;
bool isPrime(int n)
{
if (n <= 1)
return false;
for (int i = 2; i < n; i++)
if (n % i == 0)
return false;
return true;
}
bool isSumPrime(int n){
for(int i = 2; i <= n/2; ++i)
{
if (isPrime(i) == 1)
{
if (isPrime(n-i) == 1)
{
return true;
}
}
}
return false;
}
bool isPerfect(long long int n)
{
long long int sum = 1;
for (long long int i=2; i*i<=n; i++)
{
if (n%i==0)
{
if(i*i!=n)
sum = sum + i + n/i;
else
sum=sum+i;
}
}
if (sum == n && n != 1)
return true;
return false;
}
bool isSumPerfect(int n){
for(int i = 2; i <= n; ++i)
{
if (isPerfect(i) == 1)
{
if (isPerfect(n-i) == 1)
{
return true;
}
}
}
return false;
}
int fib(int n)
{
if (n <= 1)
return n;
return fib(n-1) + fib(n-2);
}
bool isFib(int n){
int i=0;
while(i<n){
if(fib(i)==n)
return true;
if(fib(i)>n)
break;
i++;
}
return false;
}
int main(int argc, char const *argv[])
{
int arr[100000], ind = 0;
while(true){
int n;
cin>>n;
if(n==-1)
break;
arr[ind] = n;
ind++;
}
for(int i=0;i<1000;i++){
if(isPrime(arr[i]) || isPerfect(arr[i]) || isSumPrime(arr[i]) ||
isSumPerfect(arr[i]) || isFib(arr[i]))
cout<<arr[i]<<endl;
}
return 0;
}



Here we are taking input till the user input -1 and then we are having the no. in the array, now we made some function to check wether the number is prime, perfect, sum of prime or perfect , comes in fib series, and then by checking every number in the array, we are checking it any of the above condition becomes true, then print the number.
Write a C++ program that reads in a list of integers, separated by a space, into...
[C++] Write a program that reads a list of integers, and outputs those integers in reverse. You must use an array for this lab. The input begins with an integer indicating the number of integers that follow. For coding simplicity, follow each output integer by a space, including the last one. Ex: If the input is: 5 2 4 6 8 10 the output is: 10 8 6 4 2 5 To achieve the above, first read the integers into...
Consider the following program that reads a number of nonnegative integers into an array and prints the contents of the array. Complete the missing parts, add new function prototypes and function definitions, and test the program several times. Add the following to the program: Write a void function that prints the list of nonnegative integers in reverse. Write a void function that prints all the numbers stored in the list that are greater than 10. It will also print the...
In C++: Write a program that reads a list of integers, and outputs the two smallest integers in the list, in ascending order. The list is preceded by an integer indicating how many numbers are in the list. If the input is: 5 10 5 3 21 2, the output is: 2 3 To achieve the above, first read the integers into a vector.
Write a program that reads a list of integers ending with a negative, and that then outputs that list in reverse. After the negative that ends the list, a character indicates what character should separate the output integers. If the input is: 3 5 2 - 1 * the output is: 2*5*3 LAB ACTIVITY 7.16.1: LAB: Reverse a list, with separating characters 2 / 10 main.cpp Load default template... 6 7 8 int numbers [100],i=0, num, size; char character; cin>>num;...
C++ please
Question 4: 125 points] Write and test a program that reads two positive integers nl and n2 with n2 > nl. The program then calculates the sum of the prime numbers, using is prime () function developed above, between nl and n2 (inclusive) A Sample input Enter values for nl and n2 (nl<n2): 3 9 Output: Thé Sum of prime numbers between 3 and 9 (inclusive) is 15
Write a program that reads integers ,one per line and displays their sum .Also display all the numbers read ,each with an annotation giving its percentage contribution to the sum. Use a method that takes the entire array as one argument and returns the sum of the numbers in the array. Hint: Ask user the user for the number of integers to be entered, create an array of that length ,and then fill the array with the integers read. A...
Task 1 : Write a Java program that prompts for and reads 10 integers from the user into an integer array of size 10, it then: - calculates the sum and average of positive numbers of the array and displays them. [Note: consider 0 as positive] Note: The program must display the message: "There are no positive values" if the array does not contain any positive value.
Must use Array. Must be in JAVA. Write a program that uses a Scanner object to read in a sequence of integers. The first number in the sequence represents the number of integers in the sequence (i.e., do NOT include the first number as part of the sequence). Create an array of integers that is the same size as the number of integers. Then the program will read each integer and place it in the array. Print the content of...
C++ Programming question
Problem: 5. Write a program that reads in a list of integers into an array with base type int. Provide the facility to either read this array from the keyboard or from a file, at the user's option. If the user chooses file input, the program should request a file name. You may assume that there are fewer than 50 entries in the array. Your program determines how many entries there are. The output is to be...
C programming! Write a program that reads integers until 0 and prints the sum of values on odd positions minus the sum of values on even positions. Let ?1, ?2, … , ??, 0 be the input sequence. Then the program prints the value of ?1 − ?2 + ?3 − ?4 + ⋯ ??. The input is a sequence of integers that always contains at least 0 and the output will be a single number. For example, for input...