logo

Courses with this lesson

Quick introduction to functions

#include <stdio.h> #include <stdlib.h> #include <string.h> void fibo(int k) { int n1, n2, x; int i; n1 = 0; n2 = 1; for (i = 0; i < k - 2; i++) { x = n2; n2 = n1 + n2; n1 = x; } printf("The %dth number: %d\n", k, n2); } int main(int argc, char* argv[]) { fibo(6); fibo(17); return 0; }