5bb
Aim:-Write
a C Program illustrating Factorial without Recursion.
Program:-
#include <stdio.h>
int main()
{
int c, n,
fact = 1;
printf("Enter a number to calculate it's factorial\n");
scanf("%d", &n);
for (c = 1;
c <= n; c++)
fact =
fact * c;
printf("Factorial of %d = %d\n", n, fact);
}
5bc
Aim:-Write
a c program to print fibnocci series with out recursion.
Program:-
#include<stdio.h>
int main()
{
int k,r;
int
i=0,j=1,f;
printf("Enter the number range:");
scanf("%d",&r);
printf("FIBONACCI SERIES: ");
printf("%d %d",i,j);
for(k=2;k<r;k++)
{
f=i+j;
i=j;
j=f;
printf(" %d",j);
}
return 0;
}
No comments:
Post a Comment