- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Environmental Science
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Write C program to find Exponent Power Series
Program :
A program to evaluate the power series
x2 x3 xn
ex = 1 + x + --- + --- + ..... + ----
2! 3! n!
, 0 < x < 1
It uses if……else to test the accuracy.
The power series contains the recurrence relationship of the type
Tn = Tn-1 (---) for n > 1
T1 = x for n = 1
T0 = 1
If Tn-1 (usually known as previous term) is known, then Tn (known as present term) can be easily found by
multiplying the previous term by x/n. Then
ex = T0 + T1 + T2 + ...... + Tn = sum
C Program for Exponent Series :
#include <stdio.h>
#define ACCURACY 0.0001
int main() {
int n, count;
float x, term, sum;
printf("\nEnter value of x :");
scanf("%f", &x);
n = term = sum = count = 1;
while (n <= 100) {
term = term * x / n;
sum = sum + term;
count = count + 1;
if (term < ACCURACY)
n = 999;
else
n = n + 1;
}
printf("\nTerms = %d Sum = %f", count, sum);
return 0;
}
Output :
Enter value of x:0
Terms = 2 Sum = 1.000000
Enter value of x:0.1
Terms = 5 Sum = 1.105171
Enter value of x:0.5
Terms = 7 Sum = 1.648720
Enter value of x:0.75
Terms = 8 Sum = 2.116997
Enter value of x:0.99
Terms = 9 Sum = 2.691232
Enter value of x:1
Terms = 9 Sum = 2.718279
- Related Questions & Answers
- How To Reduce the Array to 0 by decreasing elements by 1 or replacing at most K elements by 0
- Write C Program to Find Smallest Element in Array in C Programming
- Write C Program to Find Largest Element in Array in C Programming
- Write C Program to Reversing an Array Elements in C Programming
- How to Find Area of Scalene Triangle using C
- How to get a list of parameter names inside Python function?
- Recursive program to linearly search an element in a given array using C
- How to find gretest in 3 number using C Programming
- Write C Program to Find Factorial of Number Using Recursion
- How to find sum of two numbers using C Language
- Write C Program to Delete duplicate elements from an array
- Write C program to find Exponent Power Series
- How to convert temperature from degree centigrade to Fahrenheit using C
- How to Check Whether Number is Perfect Or Not using C
- How to redirect HTTP to HTTPS Using htaccess
- How to reverse a given number using C
Advertisements
ads