Programs in C language
11. To generate the first n terms of the Fibonacci sequence.#include<stdio.h> void main() { int num1=0, num2=1,no,counter,fab; clrscr(); printf("Enter a number: "); scanf("%d",&no); printf("\t%d %d",num1,num2); for(counter = 1; counter <= no-2; counter++) { fab=num1 + num2; printf(" %d",fab); num1=num2; num2=fab; } getch(); }Input :
10
Output :
0,1,1,2,3,5,8
Father of C Language
Died: October 9, 2011, Murray Hill
Dennis Ritchie
Born: September 9, 1941, BronxvilleDied: October 9, 2011, Murray Hill