#include
int* fib(int);
int main()
{
int count;
std::cout<<\"enter number up to which fibonacci series is to be printed\"<
First, you don't have to allocate int *p=new int[count];
inside main, because you will recieve from the fib
function a pointer to an already alocated memory.
Secondly, everything that is after a return
statement is unreachable code, so you can either remove it, or move it before return
.
Furthermore, if you delete the array inside fib
function, you will return a null pointer.
And the main problem is at:
for(i<0;i<=count;i++)
whom correct for is:
for(i = 0; i <= count; i++)