Program to print the following series until there sum exceeds 2.6 term value exceeds 1.5 - 100 Most Important C# Programs

100 Most Important C# Programs

76. Program to print the following series until there sum exceeds 2.6 term value exceeds 1.5 x+x2/2!+x3/3!+------------.

Code:

#include<stdio.h>

#include<conio.h>

main( )

{

float x,sum=0,prod=1;

int i;

clrscr( );

printf(“enter x value”);

scanf(“%f’,&x);

i=1;

while((sum<2.6)&&(prod<=1.5))

{

prod=prod*(x/i);

if(prod<=1.5)

sum=sum+prod;

if(sum>2.6)

{

sum=sum-prod;

break;

}

printf(“sum=;%f’,sum);

i++;

}

getch( );

}