📌  相关文章
📜  c program for fibonacci series - C 编程语言代码示例

📅  最后修改于: 2022-03-11 15:04:39.550000             🧑  作者: Mango

代码示例2
#include 
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;
    }  
}