#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
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Jaganathan BantheswaranPosted Nov 22, 2013, 11:20 PM
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;
}
Ramesh MaruthiPosted Nov 22, 2013, 3:32 PM
#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 :)