Iterative Fibonacci code in Java?

In fibonacci sequence each item is the sum of the previous two. So, you wrote a recursive algorithm. So, Now you already know fibonacci(1)==1 and fibonacci(0) == 0. So, you can subsequently calculate the other values. Now, And from fibonacci sequence 0,1,1,2,3,5,8,13,21…. we can see that for 5th element the fibonacci sequence returns 5. like … Read more

How to iterate over a string in C?

You want: sizeof gives you the size of the pointer, not the string. However, it would have worked if you had declared the pointer as an array: but if you pass the array to function, that too will decay to a pointer. For strings it’s best to always use strlen. And note what others have … Read more