Question
Write a program that gets an integer value from the user. Then it finds and displays its factorial using the following approximation




Use the function pow(x,n) and exp(x) from math.h

3 f= n! = nn e n
0 0
Add a comment Improve this question Transcribed image text
Answer #1

The code is

#include<stdio.h>
#include <math.h>
int main() {
int n;
printf("Enter the value of N\n");
scanf("%d",&n);
double f =pow(n,n)*exp(-n)*sqrt((2*n+(1/3))*3.1415);
printf("The value of factorial is %lf",f);
}

The output is

Enter the value of N 6
The value of factorial is 710.067714

Do give a thumbs up Thanks

Add a comment
Know the answer?
Add Answer to:
Write a program that gets an integer value from the user. Then it finds and displays...
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
  • c++ please (1) Write a program that prompts the user to enter an integer value N...

    c++ please (1) Write a program that prompts the user to enter an integer value N which will rpresent the parameter to be sent to a function. Use the format below. Then write a function named CubicRoot The function will receive the parameter N and return'its cubic value. In the main program print the message: (30 Points) Enter an integer N: [. ..1 The cubic root of I.. ] is 2 update the code om part and write another function...

  • In java, write a program that gets 10 integer numbers from the user using user input,...

    In java, write a program that gets 10 integer numbers from the user using user input, and then calculates and display the sum of the numbers that have been read.   Program Requirements: Write the program in three versions with three loops. Put all three loops in the main method of your source code. version1:  use a while loop. version2:  use a do-while loop. version 3:  use a for loop. For each version, use a loop to input 10 int numbers from the user...

  • In java, write a program that gets 10 integer numbers from the user using user input,...

    In java, write a program that gets 10 integer numbers from the user using user input, and then calculates and display the sum of the numbers that have been read.   Program Requirements: Write the program in three versions with three loops. Put all three loops in the main method of your source code. The program must be in one file. version1:  use a while loop. version2:  use a do-while loop. version 3:  use a for loop. For each version, use a loop to...

  • Write a program that takes a positive integer n as input from the user and displays...

    Write a program that takes a positive integer n as input from the user and displays an n by n checkerboard. (Hint: your main method could do user input then call the constructor for your GUI with n as the argument.) For example, when n = 5, there are 25 alternating white and black squares inside a square boarder. The lower right corner of the overall pattern must be white. Make sure that adjacent squares are different colors regardless of...

  • Write a program that reads an integer k from user and finds the number of elements...

    Write a program that reads an integer k from user and finds the number of elements that are divisible by k in the file assignment4.txt. A number n is divisible by k if n = kx for some integer x > 0. You can use the mod operator % to test for divisibility. The file assign4.txt has integer values in the range [0,100 ]. You should use end-of-file controlled loop for this problem. Sample execution is given below. Assume the...

  • QUESTION 12 Write a program that would prompt the user to enter an integer. The program...

    QUESTION 12 Write a program that would prompt the user to enter an integer. The program then would displays a table of squares and cubes from 1 to the value entered by the user. The program should prompt the user to continue if they wish. Name your class NumberPowers.java, add header and sample output as block comments and uploaded it to this link. Use these formulas for calculating squares and cubes are: square = x * x cube = x...

  • 4- Write a program by using function that asks the user for entering a positive integer...

    4- Write a program by using function that asks the user for entering a positive integer number (a) and then calculate the factorial of the number. Draw the Trace Table (8 Marks)( k/2, T/2, C/2, A/2) Enter a number: 4 Factorial (4) = 4! =4*3*2*1=24 use python pls

  • USING PYTHON LANGUAGE. QUESTION I: Write a program that displays the following table: a a^2 a...

    USING PYTHON LANGUAGE. QUESTION I: Write a program that displays the following table: a a^2 a 3 a14 1 1 1 1 2 4 8 16 3 9 27 81 4 16 64 256 QUESTION II: An approximate value of a number can be computed using the following formula: 7 ) Write a program that displays the result of 4 X + 7 • H) and 4 X - 를 7 tis). 9 QUESTION III: Write a program that prompts...

  • For Python: Write a program that gets five integer test scores from the user, calculates their...

    For Python: Write a program that gets five integer test scores from the user, calculates their average, and prints it on the screen. Test your program with the following data: Run 1: 40, 80, 97, 32, 87 Run 2: 60, 90, 100, 99, 95

  • Write a program that accepts a String value from the user and displays the reverse of...

    Write a program that accepts a String value from the user and displays the reverse of that value. For additional challenge, determine if the String and its reverse are equal and display a message explaining the result.

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