Number Pattern Program in C - 50


program for pattern in c


/*
Write a program in C for Number Pattern Program
*/

#include<stdio.h>
int fib(int);

int main()
{
  int i,j,k=1;
  for(i=1;i<=5;i++)
  {
    for(j=1;j<=i;j++)
    {
      printf("%d ",fib(k++));
    }
    printf("\n");
  }
  return 0;
}

int fib(int n)
{
  if(n<=1)
    return n;
  return(fib(n-1)+fib(n-2));
}

Post a Comment

0 Comments