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
  • Using Dev C++, write a program to solve the problem as stated below. Write a program...

    Using Dev C++, write a program to solve the problem as stated below. Write a program will input a single integer value (all input will be exactly 8 digits long) and will store pairs of digits as individual integer values. The program will display the five 2-digit numbers as well as the average of these, each on their own line. Use a switch statement to print out Grade: and then either A (>=90), B ([80..89]), C ([70..79]), D ([60..69]) or...

  • 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

  • Using Dev C++, write a program to solve the problem as stated below. Make use of...

    Using Dev C++, write a program to solve the problem as stated below. Make use of a repetition structure (counter-controlled while loop) to shorten part of your code Dont use array. Write a program will input a single integer value (all input will be exactly 8 digits long) and will store pairs of digits as individual integer values. The program will display the five 2-digit numbers as well as the average of these, each on their own line. Use a...

  • 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...

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