#include
What's he error in this program:
am getting ELEMENTS NOT FOUND, everytime. what's he error in this program:
#include
#include
int main()
{
int a[5]={2,4,6,8,10};
int Item;
int i = 0;
while(i<5)
{
if(a[i]==Item)
{
cout<
#include
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.


Ramesh MaruthiRank #937 · 2.2K reputationPosted Nov 22, 2013, 10:32 AM EST
#include
int main()
{
int a[5]={2,4,6,8,10};
int Item;
int i = 0;
while(i<5)
{
if(a[i]==Item)
{
cout<
}
else
{
cout<<"Element not found";
}
i++;
}
}
try this :)
Jaganathan BantheswaranRank #170 · 14.1K reputationPosted Nov 22, 2013, 6:20 PM EST
The problem here is, you did not initialize the Item variable with the value which is in the array. So the element is no found
Working example:
#include
#include
using namespace std;
int main()
{
int a[5]={2,4,6,8,10};
int Item = 6;
int i = 0;
while(i<5)
{
if(a[i]==Item)
{
cout<
}
else
{
cout<<"Element not found";
}
i++;
}
return 0;
}