Algorithm
Input:
1. n
2. x
Output:
1. sum
Method: //main program
1. start
2. read n and x
3. print n and x
4. sums=sum_seri(n, x); //function calling
5. print"sum of series",sums
6. stop
//write the function definition before the main program
float sum_ser(int n, float x) function definition
begin
sum=1;
for(i=1; i< n; i++)
begin
sum = sum + pow(x,i);
end
return sum;
end
Input:
1. n
2. x
Output:
1. sum
Method: //main program
1. start
2. read n and x
3. print n and x
4. sums=sum_seri(n, x); //function calling
5. print"sum of series",sums
6. stop
//write the function definition before the main program
float sum_ser(int n, float x) function definition
begin
sum=1;
for(i=1; i< n; i++)
begin
sum = sum + pow(x,i);
end
return sum;
end
No comments:
Post a Comment