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