Fibonacci Array

#include<stdio.h> int main() { int n, i; printf("Number of Terms: "); scanf("%d", &n); int ara[n]; //assign the terms ara[0] = 0, ara[1] = 1; for (i = 2; i < n; i++) ara[i] = ara[i - 1] + ara[i - 2]; //print the terms printf("The First %d Fibonacci Terms are: ", n); for (i = 0; i < n; i++) printf("%d ", ara[i]); return 0; }

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.