100% C prog Hemachandra (Fibonacci) series
// Online C compiler to run C program online
#include <stdio.h>
void main()
{
int i,n,old1,old2,new;
old2=0;
old1=1;
printf("\n enter no. of terms greater than 2:");
scanf("%d",&n);
printf("hemachandra series= %3d,%3d",old2,old1);
for(i=2;i<n;i++)
{
new=old1+old2;
old2=old1;
old1=new;
printf(",%3d",new);
}
}
#include <stdio.h>
void main()
{
int i,n,old1,old2,new;
old2=0;
old1=1;
printf("\n enter no. of terms greater than 2:");
scanf("%d",&n);
printf("hemachandra series= %3d,%3d",old2,old1);
for(i=2;i<n;i++)
{
new=old1+old2;
old2=old1;
old1=new;
printf(",%3d",new);
}
}
ఔట్పుట్ తెరమీద
enter no. of terms greater than 2:7
hemachandra series= 0, 1, 1, 2, 3, 5, 8
hemachandra series= 0, 1, 1, 2, 3, 5, 8
enter no. of terms greater than 2:9
hemachandra series= 0, 1, 1, 2, 3, 5, 8, 13, 21
hemachandra series= 0, 1, 1, 2, 3, 5, 8, 13, 21
కామెంట్లు
కామెంట్ను పోస్ట్ చేయండి
దయచేసి మీ సలహాలను సూచనలను స్పష్టంగా పేర్కొనగలరు. plz see that ur comments are 'acceptable' in a value based society.