“C Programm für Fibonacci -Serie” Code-Antworten

C Programm zur Anzeige von Fibonacci Serice

//display fibonacci serice
#include<stdio.h>
#include<conio.h>
int main()
{
    int a=1,b=1,c=0,n;
    printf("\nEnter the limit: ");
    scanf("%d",&n);
    for (int i = 1; i <= 10; i++)
    {
        printf("%d, ",a);
        c= a+b;
        a=b;
        b=c;
    }
    

    return 0;
}
Cruel Chamois

C Programm für Fibonacci -Serie

//Program Name: Print fibonacci series using for loop upto n term
// for e.g 1, 1, 2, 3, 5, 8
#include <stdio.h>
void main()
{
    int s1=0,s2=1; //initializing first two numbers 
    int nextNum=0,SumUpto=0;
    printf("\n\n\tPlease enter number up to which print Fibonacci series is required \t");
    scanf("%d",&SumUpto);
    //printing first two numbers
    printf("\n\tfibbonacci Series up to %d is ",SumUpto);
    printf("\n\n\t%d  %d",s1,s2);
     for(nextNum=2;nextNum<=SumUpto;)
    {    
 	        s1=s2;    
        s2=nextNum; 
        printf(" %d",nextNum); 
        nextNum=s1+s2;
    }  
}
Elated Eel

C Programm für Fibonacci -Serie

int fibs(int a)
{ 
  if (a==0) return 0;
  else if(a==1)
    return 1;
  else
    return (fibs(a-1)+fibs(a-2));
}
Kind Kea

C Programm für Fibonacci -Serie

#include <stdio.h>
void main()
{
    int s1=0,s2=1; //initializing first two numbers 
    int nextNum=0,SumUpto=0;

    printf("\n\n\tPlease enter number up to which print Fibonacci series is required \t");
    scanf("%d",&SumUpto);
    printf("\n\tfibbonacci Series up to %d is ",SumUpto);
    printf("\n\n\t%d  %d",s1,s2);
     for(nextNum=2;nextNum<=SumUpto;)
    {    
        s1=s2;    
        s2=nextNum; 
        printf(" %d",nextNum); 
        nextNum=s1+s2;
    }  
}
Elated Eel

Ähnliche Antworten wie “C Programm für Fibonacci -Serie”

Fragen ähnlich wie “C Programm für Fibonacci -Serie”

Weitere verwandte Antworten zu “C Programm für Fibonacci -Serie” auf C

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen