Euler\'s number The number is a mathematical constant approximated at 2.718. The
ID: 3667205 • Letter: E
Question
Euler's number The number is a mathematical constant approximated at 2.718. The formula for computing it is as follows; e = 1 + 1/1! + 1/2! + 1/3! + 1/4! + Write a program Euler.c that approximates the value of e by using the following equation: e = 1 + 1/1! + 1/2! + 1/3! + 1/4! + + 1/n! where n is a number entered by the user. Your program will first compute e as 1, then as 1 + 1/11, then as 1+1/11+1/2! and so on. In print the step number and the value of e, as follows (with 20 digit after the decimal point): 2.00000000000000000000 2.25000000000000000000 After how many steps the value does not charge? Change the type of e from float to double. Does your answer change? Remove the intermediate print statement and only print the value once at the end of your problem? Compile your program into an executable called Euler. Interest Rates Write a program interest Rates. c that computes the interest amount on multiple loans. The should ask the user to enter the loan amount and the interest rate. It should then output the amount with two digits after the decimal. The program should terminate when the loan amount is 0 as in the following example (underlined numbers represent the user input): Enter loan amount ($): 15000 Enter interest rate (%): 6025 ***Interest amount ($): 937.50 Enter loan amount ($): 135 Enter interest rate (%): 21 ***Interest amount ($): 28.35 Enter loan amount ($): 0 Compile your program into an executable file called Interest Rates.Explanation / Answer
Answer :
Euler.c
#include<stdio.h>
int main ()
{
int n,i,j;
double e=1.0, e_number=1;
printf("please enter the n value");
scanf("%d", &n);
for( i =1; i<= n ; i++)
{
e_number*=i;
e = e + (1.0/ e_number);
}
printf("The value of 'e' is : %f", e);
return 0;
}
InterestRates.c
#include<stdio.h>
#include<conio.h>
int main()
{
double loan_amount,interest_rate,interest_amount;
int time=1;
printf("Enter loan amount ($): ");
scanf("%f", &loan_amount);
if(loan_amount==0)
exit(0);
printf("Enter interest rate(%) : ");
scanf("%f", &interest_rate);
interest_amount=(loan_amount*time*interest_rate)/100;
printf(" Interest amount ($): = %2f",interest_amount);
getch();
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.