Created
January 16, 2015 07:59
-
-
Save shovon/9ac38e33c87a24a3aa5c to your computer and use it in GitHub Desktop.
Me just practicing CMake
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cmake_minimum_required(VERSION 3.1.0) | |
project(fibonacci) | |
add_definitions(-std=c99) | |
add_executable(fibonacci fib.c) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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