**main program:**

__Algorithm:__
Step 1: start

Step 2: declare x,i,n,s=0,c

Step 3: read x value

Step 4: for i=0 , n=0; i<=10;
i=i+2, n++ goto step 5

Step 5:
s=s+(pow(-1,n)*pow(x,i)/fact(i))

Step 6: print s value

Step 7: stop

__Sub program:__
Step 1: while x!=0 goto Step 2

Step 2: y=y+x; x—

Step 3: return y

Step 4: return to main program

__Program:__
#include<stdio.h>

#include<math.h>

long fact(int);

void main()

{

int x,i,n;

float s=0,c;

clrscr();

printf("\n enter the value of x\t");

scanf("%d",&x);

/*perform the looping operation*/

for(i=0,n=0;i<=10;i=i+2,n++)

s=s+(pow(-1,n)*pow(x,i)/fact(i));

printf("\n the result is %f",s);

getch();

}

/* calling sub program*/

long fact(int x)

{

long int y=1;

while(x!=0)

{

y=y*x;

x--;

}

return y;

}

__Output:__
1.Enter the value of x : 1

The result is
0.540302

2 Enter the value of x: 2

The result is -0.416155

**The program is error free**

__Conclusion:__

__VIVA QUESATIONS:__
1) What
is function ?

Ans: A function is a sub
program it returns a value.

2) What
is procedure ?

Ans: A procedure is a sub program it
does not returns a value

3) What
are the basic data types in C ?

Ans: int, char, float, double

4) How
to define preprocessor ?

Ans: By using the # symbal Ex: #include<stdio.h
really amazed with this site.............

ReplyDelete