Skip to main content

C program to generate and print first N FIBONACCI numbers

This is a Program which all of the coders have written as beginners.


 /*Write a C program to generate and print first N FIBONACCI numbers*/

#include <stdio.h>
main()
{
  int   fib1=0, fib2=1, fib3, N, count=0;
  printf("Enter the value of N\n");
  scanf("%d", &N);
  printf("First %d FIBONACCI numbers are ...\n", N);
  printf("%d\n",fib1);
  printf("%d\n",fib2);
  count = 2;           /* fib1 and fib2 are already used */
  while( count < N)
  {
    fib3 = fib1 + fib2;
    count ++;
    printf("%d\n",fib3);
    fib1 = fib2;
    fib2 = fib3;
  }
}


It will Output as 


Enter the value of N
10
First 5 FIBONACCI numbers are ...
0
1
1
2
3
5
8
13
21
34

Also Read : 

1)  Principles of Server Virtualization

2) Top Ten Data Storage Tools

3) Implement a simple calculator (detailed comments on JAVA code)

4) What is a Livelock scenario in java?

5) What is Disk scheduling algorithm in java ( code Example) 

6) What is a Deadlock situation in Java? What are the minimum requirements for a Deadlock situation in a program in Java? How can we prevent a Deadlock in Java?

7) Recursion-maze problem - Rat in the Maze - Game

8) What are features ,  Advantages and disadvantages of Javascript?

9) C program to read a file and display its contents along with line numbers before each line.

10) C++ program to find LCM and HCF of given 3 numbers


11)  What is cloud computing technology and what are the concepts, principles, applications, and prospects for cloud computing technology?

12) What are the basic characteristics of enterprise cloud computing, and what are the main stages in the construction process?

13) 20 best practices for database design

14) Best practices for DB2 database index design

Comments

Popular posts from this blog

8 common methods for server performance optimization

  1. Use an in-memory database In-memory database is actually a database that puts data in memory and operates directly. Compared with the disk, the data read and write speed of the memory is several orders of magnitude higher. Saving the data in the memory can greatly improve the performance of the application compared to accessing it from the disk. The memory database abandoned the traditional way of disk data management, redesigned the architecture based on all data in memory, and made corresponding improvements in data caching, fast algorithms, and parallel operations, so the data processing speed is faster than that of traditional databases. Data processing speed is much faster.       But the problem of security can be said to be the biggest flaw in the memory database. Because the memory itself has the natural defect of power loss, when we use the memory database, we usually need to take some protection mechanisms for the data on the memory in advance, such...

Recursion-maze problem - Rat in the Maze - Game

  package com.bei.Demo01_recursion; public class MiGong {     public static void main(String[] args)  {         //First create a two-dimensional array to simulate the maze         int [][]map=new int[8][7];         //Use 1 for wall         for (int i = 0; i <7 ; i++) {             map[0][i]=1;             map[7][i]=1;         }         for (int i = 0; i <8 ; i++) {             map[i][0]=1;             map[i][6]=1;         }         //Set the bezel         map[3][1]=1;         map[3][2]=1;         //Output         for (int i = 0; i <8 ; i++) {             for (int j = 0; j ...

AirBnB Infographic Journey to IPO

  Full Post at  https://techpomelo.com/2020/10/infographics-airbnb-milestone-journey-to-ipo/