Write a program of Fibonacci Series
#include <stdio.h>
void fiber(int n)
{
static int previous=1,preprevious=0,current=0;
printf("%d ",preprevious);
if(n>1)
{
current = previous + preprevious;
preprevious=previous;
previous=current;
fiber(n-1);
}
}
void main()
{
printf("Fibonacci: ");
fiber(5);
}
Output :
Fibonacci: 0 1 1 2 3
Write a program of Pointer
#include <stdio.h>
int pointer(int * a)
{
int p=8;
printf("What is the value of adsress pointer %d value of a before ++a : %d\n",a,*a);
*++a=p;
return *a;
}
int main()
{
int p=100;
printf("After the value of increment ++p %d\n",pointer(&p));
return 0;
}
Output :
What is the value of adress pointer 82182492 value of a before ++a : 100
after the value of ++p 8