FIBONACCI WORD
In this the program will print fibonacci series of word :
if f(0)="a",f(1)="b",f(2)="ba",f(3),"bab",f(4)="babba",etc.
here program is given to print the series:
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char ch1[5]={"a"},ch2[5]={"b"},ch3[5]={"b"};
int i;
clrscr();
puts(ch1);
printf("\n");
for(i=0;i<5;i++)
{
puts(ch3);
printf("\n");
strcat(ch3,ch1);
strcpy(ch1,ch2);
strcpy(ch2,ch3);
}
getch();
}
if f(0)="a",f(1)="b",f(2)="ba",f(3),"bab",f(4)="babba",etc.
here program is given to print the series:
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char ch1[5]={"a"},ch2[5]={"b"},ch3[5]={"b"};
int i;
clrscr();
puts(ch1);
printf("\n");
for(i=0;i<5;i++)
{
puts(ch3);
printf("\n");
strcat(ch3,ch1);
strcpy(ch1,ch2);
strcpy(ch2,ch3);
}
getch();
}
Comments
Post a Comment