Skip to main content

To Generate Fibonacci series using C

#include<stdio.h>
#include<conio.h>
void main()
{
   int f1=0, f2=1, f3, num, count=0;

   clrscr();
   printf("\nEnter a Number: ");
   scanf("%d", &num);
   printf("\n%d",f1);
   printf("\n%d",f2);
   count=2;
 
     while(count<num)
     {
         f3=f1+f2;
         count++;
         printf("\n%d",f3);
         f1=f2;
         f2=f3;
      }
   getch();
}



OUTPUT:

Enter a Number: 10

0
1
1
2
3
5
8
13
21
34

Comments

Popular posts from this blog

Creating a Realtime Clock using Python program

Clock from turtle import * from datetime import datetime def jump(distanz, winkel=0):     penup()     right(winkel)     forward(distanz)     left(winkel)     pendown() def hand(laenge, spitze):     fd(laenge*1.15)     rt(90)     fd(spitze/2.0)     lt(120)     fd(spitze)     lt(120)     fd(spitze)     lt(120)     fd(spitze/2.0) def make_hand_shape(name, laenge, spitze):     reset()     jump(-laenge*0.15)     begin_poly()     hand(laenge, spitze)     end_poly()     hand_form = get_poly()     register_shape(name, hand_form) def clockface(radius):     reset()     pensize(7)     for i in range(60):         jump(radius)         if i % 5 == 0:           ...

Inserting,Deleting and Updating table values in Database using Python Programming

Insert,Delete and Update import tkinter as tk from tkinter import * import mysql.connector import datetime def IsValidDate(InputDate):     day = InputDate[:2]     month = InputDate[3:5]     year = InputDate[6:]         IsValid = True         try :         datetime.datetime(int(year),int(month),int(day))     except ValueError :         IsValid = False     return IsValid def FormatDBDate(InputDate):     dt = InputDate[6:] + "-" + InputDate[3:5] + "-" + InputDate[:2]     return dt    def FormatEDDate(InputDate):     dt =  InputDate[8:] + "/" + InputDate[5:7] + "/" + InputDate[:4]     return dt  def DeleteEmployee(id, eid, ename, dob, doj, adr, cty, pcd, mob, eml, gen, dep):     conn=mysql.connector.connect(user='root',password='harsha',host='localhost', datab...

Palindrome of a given number using C

#include<stdio.h> #include<conio.h> void main() {    long n, r, ri=0, oi;    clrscr();    printf("\nEnter a number: ");    scanf("%ld",&n);    oi = n;    while(oi!=0)    {       ri = ri * 10;       ri = ri + oi % 10;       oi = oi / 10;    }    if(n==ri)    {       printf("\nThe given number is a Palindrome");    }    else    {       printf("\nThe given number is not a palindrome");    }    getch(); } Output: Enter a number: 1221 The given number is a Palindrome Output: Enter a number: 953212359 The given number is a Palindrome