Answer to Question #252948 in C++ for aro

Question #252948

 Write the pseudocode for a program that accepts a series of integers (the user should decide  how many) and stores them in an array. The program should then pass these values one at a  time to a function called even which returns 1 if the number is even and 0 if the number is odd.


1
Expert's answer
2021-10-18T18:28:15-0400
/*Write the pseudocode for a program that accepts a series of integers (the user should decide  
how many) and stores them in an array. The program should then pass these values one at a  time to a 
function called even which returns 1 if the number is even and 0 if the number is odd.
*/
#include <iostream>


using namespace std;


int even(int n){
    if(n%2==0)
        return 1;
    else 
        return 0;
}
int main()
{
    int n;
    cout<<"\nEnter the number of elements to put in the array: ";
    cin>>n;
    int arr[n];
    cout<<"Enter elements of the array:\n";
    for(int i=0;i<n;i++){
        cin>>arr[i];
    }
    cout<<"\nNumber\tEven or not\n";
    for(int i=0;i<n;i++){
        cout<<arr[i]<<"\t"<<even(arr[i])<<endl;
    }


    return 0;
}



Sample run


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS