Skip to content

Instantly share code, notes, and snippets.

@shovon
Created January 16, 2015 07:59
Show Gist options
  • Save shovon/9ac38e33c87a24a3aa5c to your computer and use it in GitHub Desktop.
Save shovon/9ac38e33c87a24a3aa5c to your computer and use it in GitHub Desktop.
Me just practicing CMake
cmake_minimum_required(VERSION 3.1.0)
project(fibonacci)
add_definitions(-std=c99)
add_executable(fibonacci fib.c)
# include "stdio.h"
# include "stdlib.h"
int main( int argc, char** argv) {
if ( argc > 2 || argc == 1 ) {
printf("Fibonacci takes one postitive integer greater than two as it's argument\n");
return EXIT_SUCCESS;
}
int a, b;
a = 0;
b = 1;
printf( "%d", b );
for( int i = 0; i + a <= atof( argv[1] ); b = i ) {
i = a + b;
a = b;
printf( ", %d", i );
}
printf("\n");
return EXIT_SUCCESS;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment