fork download
  1. #include <stdio.h>
  2.  
  3. int main(void) {
  4. int n;
  5. printf("Enter the number: ");
  6. scanf("%d",&n);
  7.  
  8. int a=1;
  9. int b=1;
  10. int sum=0;
  11. for(int i=1;i<=n-2;i++){
  12. sum=a+b;
  13. a=b;
  14. b= sum;
  15. }
  16. printf(" The %dth term is %d",n,sum);
  17.  
  18. return 0;
  19. }
  20.  
Success #stdin #stdout 0s 5320KB
stdin
4
stdout
Enter the number:  The 4th term is 3