Archive for May 2019

Write a program in C++ to print Fibonacci series upto number entered by user

#include <iostream.h>
#include <conio.h>

int main() {   
   int n, c, first = 0, second = 1, next;
 
   cout<<"*** FIBONACCI SERIES ***"<<endl; 
   cout << "Enter number of terms: ";
   cin >> n;
   cout << endl;
   
   for ( c = 0 ; c < n ; c++ )
   {
      if ( c <= 1 )
         next = c;
      else
      {
         next = first + second;
         first = second;
         second = next;
      }
      cout << next << " ";
   }
   return 0;
}

Output:

Read more

Write a program in C++ to find factorial of entered number

#include <iostream.h>
#include <conio.h>

int main() {

 int num,factorial=1;
 
 cout << "Enter Number: ";
 cin >> num;
 
 for (int a=1;a<=num;a++) {
  factorial=factorial*a;
 }
 
 cout<<"Factorial: "<< factorial << endl;
 return 0;
}


Output:

Read more

Contact Form

Name

Email *

Message *

Followers