SUMMER TRAINING Free Tutorials  Go To Your University  Placement Preparation 
Project Based Best Summer Training Courses in Jaipur
Join our Telegram Channel To take free Online Courses
0 like 0 dislike
862 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!

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

Our Mentors(For AI-ML)


Sharda Godara Chaudhary

Mrs. Sharda Godara Chaudhary

An alumna of MNIT-Jaipur and ACCENTURE, Pune

NISHA (IIT BHU)

Ms. Nisha

An alumna of IIT-BHU

Related questions

 Goeduhub:

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