You are on page 1of 2

Program 1b:

/* Febinocii Series */
#include<stdio.h>
#include<conio.h>
int f,s,t,c,n;
main()
{clrscr();
puts("FEBINOCII SERIES");
puts("Enter how many number of febinocii numbers you want");
scanf("%d",&n);
f=0;
s=1;c=2;
printf(" 0 1 ");
do{ t=f+s;++c;
if(c>n) break;
printf("%d ",t);
f=s;
s=t;
}while(1);
getch();
}

Program 1c:

/* Prime number Generation */


#include<stdio.h>
#include<conio.h>
int p,c,e,i,n;
main()
{clrscr();
puts("Enter how many number of primes you want");
scanf("%d",&n);
c=1;e=2;
do{ p=1;++e;
for(i=2;i<e;++i)
if(e%i==0) {p=0;break;}
if(p) {printf("%d ",e);++c;
if(c>n) break;}
}while(1);
getch();
}

Output:

Program 2a:
#include<stdio.h>

float t,s;
int i,x,n,k;

float sum(int x,int n)


{ if(n==0) return(0);
if(n==1) return(1);
t=1;s=1;k=0;
for(i=2;i<=n;i++)
{ t*= (-1*x*x)/((k+1)*(k+2));k+=2;
s+=t;
}
return(s);
}
void main()
{ clrscr();
puts("Enter x and n");
scanf("%d%d",&x,&n);
printf("Sum is %f ",sum(x,n));
getch();

You might also like