Program:
#include<stdio.h>
#include<conio.h>
int main()
{
int a[5],i;
printf("Enter five
number\n");
for(i=0;i<=4;i++)
{
scanf("%d",&a[i]);
}
printf("Printing five
number");
i=0;
while(i<=4)
{
printf("\n%d",a[i]);
i++;
}
getch();
}
output:
Note: In the above Program, we have seen that we have to enter five element using for loop and scanf function. while we have printed that values using while loop.
Program 2:
#include<stdio.h>
#include<conio.h>
int main()
{
int f1=0,f2=1,f3,i=1,n;
printf("Enter the no");
scanf("%d",&n);
printf("%d%d",f1,f2);
while(i<=n)
{
f3=f1+f2;
i++;
printf("%d",f3);
f1=f2;
f2=f3;
}
getch();
}