Home › Forums › C Programming › how to create a program of Lucas No. using Turbo C › Re: how to create a program of Lucas No. using Turbo C
March 14, 2008 at 9:01 pm
#3333
yeswanth
Participant
The first few numbers of Lucas sequences which is a variation of Fibonacci sequence are sequence are
1 3 4 7 11 18 29
a) Design a program in C to generate Lucas sequence.
b) Develop a function to calculate sum of first n odd integers.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | #include <br /> #include <br /> void main()<br /> {<br /> int num,i;<br /> unsigned long n1=1,n2=3,s;<br /> clrscr();<br /> printf("nENTER A NUMBER: ");<br /> scanf("%d",&num);<br /> printf("nLUCAS SEQUENCE UPTO %d NUMBERS IS: n",num);<br /> printf("%lu %lu",n1,n2);<br /> for(i=1;i<=num-2;i++)<br /> {<br /> s=n1+n2;<br /> printf(" %lu",s);<br /> n1=n2;<br /> n2=s;<br /> }<br /> getch();<br /> } |