Thursday, 26 March 2015

Fibonacci series using Function & Pointer in C






#include<stdio.h>

void fibonacci(int *r)
{

 int a = 0, b = 1, display = 0;
 printf("fibonacci series: %d  %d ", a, b);
 display = a + b;

 while (display < *r)
 {
  printf("%d  ",display);
  a = b;
  b = display;
  display = a + b;
 }
 printf("\n");
}
int main()
{

 int m;
 printf("Enter number for fibonacci: ");
 scanf_s("%d", &m);
 fibonacci(&m);
 return 0;
}

0 comments:

Post a Comment

 

Subscribe to our Newsletter

Contact our Support

Through the contact form

Our Team Memebers