write a program to print the first 10 number of fibonacci series
Answers
Answered by
10
Hello friend...
INPUT:
// C program to print first n Fibonacci numbers
#include <stdio.h>
// Function to print first n Fibonacci Numbers
void printFibonacciNumbers(int n)
{
int f1 = 0, f2 = 1, i;
if (n < 1)
return;
for (i = 1; i <= n; i++)
{
printf("%d ", f2);
int next = f1 + f2;
f1 = f2;
f2 = next;
}
}
// Driver Code
int main()
{
printFibonacciNumbers(7);
return 0;
}
OUTPUT:
1 2 3 5 8 13
Hope this helps you...
INPUT:
// C program to print first n Fibonacci numbers
#include <stdio.h>
// Function to print first n Fibonacci Numbers
void printFibonacciNumbers(int n)
{
int f1 = 0, f2 = 1, i;
if (n < 1)
return;
for (i = 1; i <= n; i++)
{
printf("%d ", f2);
int next = f1 + f2;
f1 = f2;
f2 = next;
}
}
// Driver Code
int main()
{
printFibonacciNumbers(7);
return 0;
}
OUTPUT:
1 2 3 5 8 13
Hope this helps you...
Attachments:

Answered by
0
Question:
Write a program to find the sum of 1st 10 numbers of Fibonacci series, i.e. 1,1,2,3,5,8,13…. Fibonacci series is such a series which starting from 1 and 1, and subsequent numbers are the sum of the previous two numbers.
Solution:
Language used: Java
public class FibSum
{
static void main()
{
int i,a=1,b=0,c;
System.out.println("Fibonacci series =");
for(i=1;i<=10;i++)
{
c=a+b;
System.out.print(c+" ");
a=b;
b=c;
}
}
}
Similar questions
Hindi,
7 months ago
English,
7 months ago
Math,
7 months ago
Biology,
1 year ago
Political Science,
1 year ago
India Languages,
1 year ago
Hindi,
1 year ago
English,
1 year ago