Skip to content

Instantly share code, notes, and snippets.

@dhhdev
Last active December 4, 2017 22:16
Show Gist options
  • Save dhhdev/b1ae31ae8ad0bf8e658aad8292dc3b8c to your computer and use it in GitHub Desktop.
Save dhhdev/b1ae31ae8ad0bf8e658aad8292dc3b8c to your computer and use it in GitHub Desktop.
Fibonacci sequence between start and end term.
/*
* Fibonacci squence between start and end term.
*/
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
int a = 0;
int b = 1;
int c = 0;
int start = 10;
int end = 40;
while (c <= end)
{
if (c >= start) {
printf("%d, ", c);
}
a = b;
b = c;
c = a + b;
}
printf("\n");
return EXIT_SUCCESS;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment