Output error in the code
@ishikagoel8218
You thought in a way as using arr2 as a storage of indexes where the element βmβ is to be found.
Now its not, iteration where we just store found index in array and then increment its index.
Let me dry run your code for
4 <-- Array size
1 1 2 3
1<βto be found
You made call to count() function,this function is a recursive function.
Start variables:
si=0
arr2 is having 0 on all its indexes
m=element to be found.
After function call,
Now,Compiler meets code At line 24,which is a base case.
Now at line 28 as arr[si] i.e. arr[0] equals m=1 hence code goes to line 30 at else part.
On writing arr2[j] i.e. arr2[0]=0, it returns to main and print arr2[];
Moreover,you have printed array2 wrong.Try to use itreation to print array elements
Currently its printing array Address,Array cannot be printed with loop.
Please try to correct your logic and come back with updated code.