Fibonacci series

Program:

#include<stdio.h> 
int main() 

int n1=0,n2=1,n3,i,num; 
  printf("Enter No. of elements: \n"); 
  scanf("%d",&num); 
  printf("%d %d",n1,n2); 
  for(i=2;i<num;i++) 
 
  n3=n1+n2; 
  printf(" %d ",n3); 
  n1=n2; 
  n2=n3; 
  }
return 0;
}

Output:



No comments:

Post a Comment

x^y using recursion

Program: #include<stdio.h> int power(int a,int b); int main() { int x,y,ans; printf("Enter x and y:\n "); scanf(...