23.12.19

Generating the first n terms of fibonacci series program in c

#include<stdio.h>
void main()
{
int a=0,b=1,c=0,n,i;

printf("Enter the positive number ");
scanf("%d",&n);

printf("\nFibonacci series ");

for(i=0;i<=n;++i)
{

printf("%d",a);

c=a+b;
a=b;
b=c;
}
}

OUTPUT:

Enter the positive number 10
Fibonacci series
0
1
1
2
3
5
8
13
21
34

No comments:

Post a Comment

JAVA program pattern 2

import java.util.Scanner; public class pattern3 { public static void main(String args[]) { int i,j; Scanner sc=new Scanner(System.in); Syste...