Write the C Program in Keil Embedded C:
1. Write a program in Keil Embedded C to find factorial of a number.
#include
int main()
{
int a,b=1,c,d,ans1,ans2,i;
a=P0;p0=N;
for(i=1;i<=a;i++)
a=a*i;
P1=a;
}
2. Write a program to generate the sum of Fibonacci series for n Term,
#include
int main()
{
int a,b,c,d,ans1=1,ans2;
a=P0;// P0=0
b=P1;//P1=1;
c=P2;//P2=N;
P3=0
d=0;
for(i=0;i
{
d=a+b;
a=b;
b=d;
ans1=ans1+b;
}
P3=b;
P2=ans1;
}
3 w.a.p. to find out total prime numbers from 1 to 50 .
#include
int main()
{
int ai,j,k,cnt=0x00;
a=P0;//p0=50
for( i=2;i<=a;++i)
{
cnt=0x00;
for( j=2;j<=i/2;++j)
{
if(i%j==0)
{
cnt++;
}
if(cnt>=1)
break;
}
if(cnt==0x00)
P1=i;
}
}