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.
/*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
Comments