Question

kindly write it in c++ language. from dev c++ .Write a program to find out the factorial of an integer using loop Formula to find the factorial of an integer is: n*(n-1)*(n

0 0
Add a comment Improve this question Transcribed image text
Answer #1

PROGRAM :

type 1:

#include <iostream>
using namespace std;
unsigned int factorial(unsigned int n)
{
if (n == 0)
return 1;
return n * factorial(n - 1);
}
int main()
{
int num = (15);
cout << "Factorial of "
<< num << " is " << factorial(num) << endl;
return 0;
}

type2 :

#include <iostream>
using namespace std;
int main()
{
unsigned int n;
unsigned long long factorial = 1;

cout << "Enter a positive integer: ";
cin >> n;

for(int i = 1; i <=n; ++i)
{
factorial *= i;
}

cout << "Factorial of " << n << " = " << factorial;
return 0;
}

Add a comment
Know the answer?
Add Answer to:
kindly write it in c++ language. from dev c++ . Write a program to find out...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • I am using programming language of DEV C++, and here is my assignment. Write a program,...

    I am using programming language of DEV C++, and here is my assignment. Write a program, maxmin.c to find the maximum and minimum of values in the file maxminin.txt. Your output should look like: There are 6 values in the file The maximum value is 9.500000 The minimum value is 1.100000 and this is maxminin.txt: 8.2 1.1 3.7 2.2 9.5 4.3

  • The language has to be in C program 1. (a) rite a function, int factorial (int...

    The language has to be in C program 1. (a) rite a function, int factorial (int n), which returns n (the factorial of n, i e. 1 x2 x3 x...xn.) (b) Using int factorial (int n) above, write a program to compute 2. We want to find one of the roots of a cubic equation given by which is between 0 and 1 by an iterative method. Modify the equation above to 1 x Start with an appropriate initial value...

  • i need this program in DEV C and starts with include stdio.h only Write a program...

    i need this program in DEV C and starts with include stdio.h only Write a program that receives two input values: a float number x=0, and an integer N>3. The program should output Y, which is the product of all the N numbers divided by x.

  • Using c++.. 1. Write a program to find the sum(), Subtraction(), Multiplication(), Division() operations using Switch...

    Using c++.. 1. Write a program to find the sum(), Subtraction(), Multiplication(), Division() operations using Switch statement and functions. 2. Write a program to find the summation of N numbers. Use two functions. One function will take the input from user and the other will perform the summation from 1 to N. 3. Write a program to find the factorial of a number. Use two functions. One function will take the input from user and the other will perform the...

  • in c++ language 1.Re-write the following for loop statement by using a while loop statement: int...

    in c++ language 1.Re-write the following for loop statement by using a while loop statement: int sum = 0; for(int i=0;i<=1000;i++){                 sum+=i; } 1 (b). Following is the main () function of a program. The program asks a user to enter 150 integers and print the largest integer user entered. int main() {    int score, highest;             //missing portion of the program             return 0;    } 1(c). Find the missing portion of the following code, so the...

  • This program is in C language: Write a statement that reads a decimal integer from standard...

    This program is in C language: Write a statement that reads a decimal integer from standard input and stores it into a variable named boxes. -------------------------------- Everything I enter is wrong, can someone help me out.

  • Write a C program to add and subtract any two given integer numbers using pointers

    1- Write a C program to add and subtract any two given integer numbers using pointers.  2- Write a C program to find the factorial using a function and pointers.  3- Write a C program to find the square of an Integer number using a function and pointers.  4- Write a C program to find the area and perimeter of a rectangle using a function and pointers.  5- Write a C program to find the larger of two integers numbers using...

  • it's in C programming language 3. Write a program to find out if the first two...

    it's in C programming language 3. Write a program to find out if the first two bits of an input hex number is 11and will print "the first two bits are ones" 4- Write a program that will perform the following: Check the first two numbers of an input data if they are 11 and will print "open door 1" if so, otherwise Check the last two bits of that number if they are 11 and print" Open door 2...

  • Part A Write a Java program that reads an integer n from the keyboard and loops...

    Part A Write a Java program that reads an integer n from the keyboard and loops until −13 ≤ n ≤ 13 is successfully entered. A do-while loop is advised. Part B Write a Java program that reads an integer n from the keyboard and prints the corresponding value n!. [This is n factorial]. You must verify that the input integer satisfies the constraint 0 ≤ n ≤ 13; keep looping until the constraint is satisfied.   Will give thumbs up...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT