Online Courses
Free Tutorials  Go to Your University  Placement Preparation 
0 like 0 dislike
3.6k views
in GTU B.E. (CSE-I-Sem) Programming For Problem Solving Lab by Goeduhub's Expert (7.1k points)

Write a C program to use recursive calls to evaluate F(x) = x – x*3 / 3! + x*5 / 5 ! – x*7 / 7! + … x*n/ n!

Goeduhub's Top Online Courses @Udemy

For Indian Students- INR 360/- || For International Students- $9.99/-

S.No.

Course Name

 Coupon

1.

Tensorflow 2 & Keras:Deep Learning & Artificial Intelligence || Labeled as Highest Rated Course by Udemy

Apply Coupon

2.

Complete Machine Learning & Data Science with Python| ML A-Z Apply Coupon

3.

Complete Python Programming from scratch | Python Projects Apply Coupon
    More Courses

1 Answer

0 like 0 dislike
by Goeduhub's Expert (7.1k points)
edited by
 
Best answer

Series Solving Using Recursion

In this program we are going to evaluate sum of the series given in question above.

To learn basics of function in C programming Click Here.

Example :

#include<stdio.h>
#include<conio.h>
long float recursion(float n);
void main()
{
float x,ser=0,ser1=0,i,sum=0,z,n;
clrscr();

//To take x from user
printf("\nEnter x:");
scanf("%f",&x);

printf("\nEnter n:");
scanf("%f",&n);

//To calculate positive part of series
for(i=1;i<=n;i+=4)
ser=ser+(x*i)/recursion(i);
//To calculate negative part of series
for(i=3;i<n;i+=4)
ser1=ser1+(x*i)/recursion(i);

//Sum of series
sum=ser-ser1;
//printf("%f",ser);
//To print series and it's sum
printf("\nSum of series = %.4f",sum);
getch();
}

//To calculate factorial of base value
long float recursion(float n)
{
if (n>=1)
return n*recursion(n-1);
else
return 1;
}

Output :

Output of above program showing sum of seriese


For More GTU C Programming Lab Experiments Click Here

3.3k questions

7.1k answers

394 comments

4.6k users

Related questions

 Goeduhub:

About Us | Contact Us || Terms & Conditions | Privacy Policy || Youtube Channel || Telegram Channel © goeduhub.com Social::   |  | 
...