Question:Fibonacci series in c using while loop 

Answer 
#include<stdio.h>
int main(){
    int k=2,r;
    long int i=0l,j=1,f;

    printf("Enter the number range:");
    scanf("%d",&r);

    printf("Fibonacci series is: %ld %ld",i,j);

    while(k<r){
         f=i+j;
         i=j;
         j=f;
         printf(" %ld",j);
          k++;
    }
  
    return 0;
}
Sample output: Enter the number range: 10 Fibonacci series is: 0 1 1 2 3 5 8 13 21 34 

+ ExplanationNot Moderated
+ Report
Total Preview: 569
Fibonacci series in c using while loop
Copyright © 2024. Powered by Intellect Software Ltd