-
How to be a C programmer - part 4
Ok, that's for the very, very basics. Let's do something a bit more complicated. The following program does compute the first 10 Fibonacci numbers. I must admit I didn't compile this so minor errors are a possibility. ( I writing from a cyber cafe so compiling here is not practical.)
------------------------------------------------------------------------------------------
#include "stdio.h"
// text after these two forward slashes means comment
// the compiler ignores everything on the line
/*
everything inside those symbols
means comment too
*/
int fibonacci (int n);
void main( ){
int i = 1;
int j = 0;
while( i < 11){
j = fibonacci(i);
printf("Fibonacci number %d is %d\n", i, j);
i = i + 1;
}
}
// program to be continued in part 5
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
Bookmarks