# Thread: hwhere to put the msg in Fabonacci series

1. ## hwhere to put the msg in Fabonacci series

Hi friends

I am having trouble putting the "not a fabonacci number" msg in my code

, plz help

/*
Name: fabonacci series and searching of element
Author:
Date: 14/12/10 01:29
Description:
*/
14/12/10 01:29
#include<iostream.h>
#include<conio.h>

int main()

{
int fab,x1=0,x2=1,no,a[18];

for(int i=0;i<18;i++)
{
fab=x2+x1;
x1=x2;
x2=fab;
a[i]=fab;
cout<<fab<<" ";
}

cout<<"\n\n enter the no to test :";
cin>>no;

for(int j=0;j<18;j++)

{
if(a[j]==no )
{
cout<<"\n\n Fabonacci";
break;
}
}
getch();
}

2. Originally Posted by deva
Hi friends

I am having trouble putting the "not a fabonacci number" msg in my code

, plz help

Code:
```/*
Name: fabonacci series and searching of element
Author:
Date: 14/12/10 01:29
Description:
*/
14/12/10 01:29
#include<iostream.h>
#include<conio.h>

int main()

{
int fab,x1=0,x2=1,no,a[18];

for(int i=0;i<18;i++)
{
fab=x2+x1;
x1=x2;
x2=fab;
a[i]=fab;
cout<<fab<<"  ";
}

cout<<"\n\n enter the no to test :";
cin>>no;

for(int j=0;j<18;j++)

{
if(a[j]==no )
{
cout<<"\n\n Fabonacci";
break;
}
}
getch();```
}
you can't really do that in the for loop. How about checking for true or false in the for loop and then write the statement outside.

Code:
```bool fib = false;
for(int j=0;j<18;j++)
{
if(a[j]==no )
{
fib = true;
break;
}
}
if ( fib == true)
std::cout << no << " is a fib" << std::endl;
else
std::cout << no << " is not a fib << std::endl;```

3. Did you see this popup when you submitted your code?

If you did, what did you do about it?