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
Can you please explain the difference between syntax vs logical error?
write a programe to accept any two number and check the following condition using goto state ment.if a>b,print a & find whether it is even or odd and then print.and a
Do you know the difference between malloc() and calloc() function?
how to create duplicate link list using C???
What is typedef example?
What is the advantage of a random access file?
the question is that what you have been doing all these periods (one year gap)
What is the scope of static variable in c?
What does volatile do?
What is difference between array and pointer in c?
What is wild pointer in c with example?
What is a static variable in c?
Why is it that not all header files are declared in every C program?
What is meant by initialization and how we initialize a variable?
What is Dynamic memory allocation in C? Name the dynamic allocation functions.