c++ programs for practice

Here you can find sample and simple c++ programs that are helpful for computer science students

Pages

  • Home
  • About Me
  • Share Your Programs

Wednesday, July 24, 2013

Program to find the factorial of a number using function

#include<iostream.h>
#include<conio.h>
int fact(int);
void main()
{
clrscr();
int n,f;
cout<<"Enter a number : ";
cin>>n;
f=fact(n);
cout<<"Factorial of the given number is : "<<f;
getch();
}
int fact(int n)
{
int x;
if(n==1)
x=1;
else
x=n*fact(n-1);
return(x);
}
Posted by Athul KV at 9:26 PM
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Labels: function, if-else, mathematical calculations

No comments:

Post a Comment

Newer Post Older Post Home
Subscribe to: Post Comments (Atom)

Popular Posts

  • Program for multiplication of matrix using " class "
  • Program to enter your height in centimeters and convert into feet and inches
  • Program for Newton's Law of Gravitation
  • Program To Find Out The Final Velocity Of A Body Using Linear Motion Equation
  • Program to display all prime numbers less than 100
  • Program to accept 20 numbers and display it in ascending order and descending order - Bubble sort
  • Program to find out Economic Order Quantity (EOQ)
  • Program to find the sum of all the elements of a matrix
  • Program to find out the volume of cone
  • Program to print the sum of first n natural numbers using " while loop "

About Me

My photo
Athul KV
View my complete profile

Labels

  • array (4)
  • bubble sort (1)
  • class (1)
  • conditional operator (1)
  • do-while loop (1)
  • for loop (21)
  • function (3)
  • if-else (10)
  • linear search (1)
  • loop (10)
  • mathematical calculations (19)
  • matrix (4)
  • nested loop (8)
  • new and delete operators (1)
  • pointer (1)
  • string (3)
  • switch (1)
  • two dimensional array (5)
  • while loop (4)

Facebook Fans

Blog Archive

  • ►  2014 (1)
    • ►  December (1)
  • ▼  2013 (44)
    • ►  November (1)
    • ►  October (2)
    • ►  August (6)
    • ▼  July (35)
      • Program to display all prime numbers less than 100
      • Program to insert new element in an array
      • Program to reversing a string
      • Program for multiplication of matrix using " class "
      • Program to find out the sum of two matrices
      • Program to find n!/(r!(n-r)!)
      • Program to accept 20 numbers and display it in asc...
      • Program to find the sum of all the elements of a m...
      • Program to find the volume of tray
      • Program to calculate the area of circle
      • Program to access the elements in two dimensional ...
      • Program to generate the first n elements of a Fibo...
      • Program to find the factorial of a number using fu...
      • Program to calculate the area of a triangle
      • Program to convert temperature in Celsius to Fahre...
      • Program to enter your height in centimeters and co...
      • Program to count the number of lower case vowels i...
      • Program to access the marks of 3 students and disp...
      • Program to convert Binary into Decimal number
      • Program to check whether a number is palindrome or...
      • Program to find whether two strings contain equal ...
      • Program to find the roots of a quadratic equation
      • Program to find the largest number from a set of '...
      • Program to read a string and to count the number o...
      • Program to input characters and change their case ...
      • Program using " Nested loop "
      • Program to check whether a given number is prime o...
      • Program to print the sum of first n natural number...
      • Program to print the multiplication of a given num...
      • Program using switch statement - Accept day number...
      • Program to find the biggest of two numbers using c...
      • Program to find the biggest among three numbers
      • Program to check whether a given number is odd or ...
      • About My Blog
      • History of C++

Contact Form

Name

Email *

Message *

Total Pageviews

c++ programs for practice Donot Copy. Powered by Blogger.