+ 1
Function Series of input
Write a C++ program to take series of numbers as input and give output 1 if even and 0 if odd using functions
7 Antworten
+ 3
not right order in first loop parenthesis:
for (int i=0; i++; i<size)
must be:
for (int i=0; i<size; i++)
not correct operator used in check function:
if (arr[i] / 2==0)
must be:
if (arr[i] % 2==0)
+ 2
visph sure !! 😅😅🤝
+ 1
#include <iostream>
using namespace std;
void check (int[],int );
int main()
{ int size;
cout<<" how many numbers you want to enter ? ";
cin>>size ;
int arr[size];
for(int i=0;i++;i<size)
{
cin>>arr[i];
}
check (arr,size);
}
void check (int arr[],int size)
{
for(int i =0;i <size; i++)
if (arr[i] / 2==0)
{
cout<<" 1 "<<endl;
}
else
{
cout<<" 0 "<< endl;
}
}
This was my attempt but it didn't work
+ 1
Thanks
+ 1
Finally 😌
#include <iostream>
using namespace std;
void check (int[],int );
int main()
{ int size;
int arr[size];
cout<<" how many numbers you want to enter ? ";
cin>>size;
cout<<"Enter numbers"<<endl;
for(int i=0;i<size;i++)
{
cin>>arr[i];
}
check (arr,size);
return 0;
}
void check (int arr[],int size)
{
for(int i =0;i <size; i++)
if (arr[i] % 2==0)
{
cout<<" 1 "<<endl;
}
else
{
cout<<" 0 "<< endl;
}
}
+ 1
Guru patel don't mark your own answer as best: it's not true and it's unfair (I give you the corrections to be done) and it will not give you any xp ^^
- 2
2==0