Description:
In this program we have to
read the two numbers and the calculate the sum of this geometric progression in
above mention .
Algorithm:
Step
1: Start
Step 2: read values of x and n, sum=1, i=1
Step 3: check for n & X
i)
if
n<=0 || x<=0
ii)
print
values are not valid
iii)
read values of x and n Step 4: perform the
loop operation
i)
for(i=1;i<=n;i++)
then follows
ii)
sum=sum+pow(x,i)
Step
5: print sum
Step
6: Stop
1.Enter the values for x and n:2 3
Value is valid Sum of series=15
2.Enter the values for x and n:4 9
Value is valid Sum of series=21845
3.Enter the values for x and n:01
Value is not valid
Conclusion: the program is error free
VIVA QUESTIONS:
1) what is the difference between structures and unions ?
Ans: Here the major difference is with in the structure all elements must be allocated memory. But in union highest memory allocation must be allocated to all these elements.
No comments:
Post a Comment