Download as pdf
Download as pdf
You are on page 1of 6

Question 10

C++ assignemnt

Q.10(A):
Answer:

A Program that generates faconic series up to (1 1 2 3 5 8 12 21..)

PRORGAM
#include<constream.h> #include<iostream.h> void main() { clrscr(); unsigned long limit=4294967295; unsigned long next=0; unsigned long last=1; while( next<limit /2) { cout<<last<<" "; long sum=next+last ; next=last; last=sum; } cout<<endl; getch(); }

09CE37 23

Question 10

C++ assignemnt

OUTPUT

09CE37 24

Question 10

C++ assignemnt

Q.10(B):
Answer:

) A program that determine whether a number is prime or not ?

PRORGAM
#include<constream.h> void main() { int n;

clrscr(); cout<<"Enter number"; cin>>n; for (int j=2; j<=n/2;j++) if ( n%j ==0 ) { cout<<"its not prime"; break; cout<<"its a prime\n "; } getch(); }

09CE37 25

Question 10

C++ assignemnt

OUTPUT

09CE37 26

Question 10

C++ assignemnt

Q.10(C):
Answer:

) A program that tells the factorial of numbers ?

PRORGAM

#include<constream.h> void main() { clrscr(); int x,i; cout<<"Enter Number:"; cin>>x; int fact=1; for(i=x; i>=1; i--) fact=fact*i; cout<<"The factorial is: "<<x<<"="<<fact; getch(); }

09CE37 27

Question 10

C++ assignemnt

OUTPUT

09CE37 28

You might also like