Write a program for the following series:
1*3*5-2*4*6+3*5*7-4*6*8+.................up to nterms
Answer Posted / sanath
#include <iostream.h>
void main()
{
int nTerm;
int x=1,y=3,z=5,mul1,total=0;
cout<<"Enter the NTerm:";
cin>>nTerm;
for(int i=1;i<=nTerm;i++)
{
mul1 = ((x++)*(y++)*(z++));
if(i%2)
total = total + mul1;
else
total = total - mul1;
}
cout<<"RESULT:"<<total<<endl;
}
| Is This Answer Correct ? | 2 Yes | 0 No |
Post New Answer View All Answers
What is variable and explain rules to declare variable in c?
What is the meaning of ?
What is pointer in c?
write a program to print data of 5 five students with structures?
What is union in c?
Is c is a procedural language?
What is an expression?
Write a program to find factorial of a number using recursive function.
What is the sizeof () operator?
what is the height of tree if leaf node is at level 3. please explain
Give basis knowledge of web designing ...
How to delete a node from linked list w/o using collectons?
How can you return multiple values from a function?
Is it possible to pass an entire structure to functions?
How do we open a binary file in Read/Write mode in C?