#include<stdio.h>
#include<conio.h>
int main()
{
int n1=0,n2=1,n3=1,n,i;
clrscr();
printf("Enter the Number : ");
scanf("%d",&n);
printf("\n");
for(i=1;i<=n;i++)
{
printf(" %d ",n3);
n3=n1+n2;
n1=n2;
n2=n3;
}
getch();
return 0;
}
Output:
Enter the Number : 5
1 1 2 3 5
#include<conio.h>
int main()
{
int n1=0,n2=1,n3=1,n,i;
clrscr();
printf("Enter the Number : ");
scanf("%d",&n);
printf("\n");
for(i=1;i<=n;i++)
{
printf(" %d ",n3);
n3=n1+n2;
n1=n2;
n2=n3;
}
getch();
return 0;
}
Output:
Enter the Number : 5
1 1 2 3 5
No comments:
Post a Comment