Page 258 - Computer science 868 Class 12
P. 258
16 System. out.println ("Enter number of terms");
17 n = Sc.nextInt();
18 }
19
20 void generate()
21 {
22 System. out.print(x+","+y);
23 for(int i=0; i<=n-2; i++)
24 {
25 System.out.print(","+z);
26 x=y;
27 y=z;
28 z=y+x;
29 }
30 }
31
32 public static void main()
33 {
34 FiboString obj=new FiboString();
35 obj.accept();
36 obj.generate();
37 }
38 }
The output of the preceding program is as follows:
Enter number of terms
5
a, b, ba, bab, babba, babbabab
256256 Touchpad Computer Science-XII

