Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

)a

>include <stdio.h#

{ )(int main

;int number,n

;int factorial=1

;printf("enter the integer number:")

;scanf("%d",&number)

{ if(number>0)

;printf("the value of number is right\n")

;for(n=number; n>=1;n--) { factorial=factorial*n

;printf("factorial :%d\n",factorial)

;else { printf("the valueof number is not right")

;return 0

)b

>include<stdio.h#

{)(int main

;int n

;float sum = 0

;float term = 1

;float factorial = 1

;printf("enter theinteger number :")

;scanf("%d",&n)

for(int m =1;m <= n; m++)


{

;factorial*=m

;term =(m/(factorial))

;sum +=term

;printf("sum of theseries :%f ",sum)

;return 0

)c

#include <stdio.h>
int main() {
int n;
float x, expValue = 1.0, term = 1.0;
printf("Enter the value of x: ")
; scanf("%f", &x);
printf("Enter the number of terms for estimating e^x: ");
scanf("%d", &n);
for (int i = 1; i <= n; i++)
{
term *= x / i;
expValue += term;
}
printf("Estimated value of e^x: %.4f\n", expValue);
return 0;
}

You might also like