Completely Solved C, C++ Programs Assignment.




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

Filed Under:

Problem 76. C Program to print the following series until there sum exceeds 2.6 term value exceeds 1.5 x+x2/2!+x3/3!+------------.
#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( );
}

C compiler: gcc 4.1.2

 Back to main directory: Sample C Program | Software Practical | Solved C Assignment


Get Free Programming Tutorials and Solved assignments