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


Please Help Members By Posting Answers For Below Questions

program to find error in linklist.(i.e find whether any node point wrongly to previous nodes instead of next node)

1626


How can I send mail from within a c program?

580


What is a buffer in c?

575


A float occupies 4 bytes in memory. How many bits are used to store exponent part? since we can have up to 38 number for exponent so 2 ki power 6 6, 6 bits will be used. If 6 bits are used why do not we have up to 64 numbers in exponent?

1775


How can you find the day of the week given the date?

615






What is dynamic dispatch in c++?

556


while initialization of array why we use a[][2] why not a[2][]...?

1863


write a program to display all prime numbers

1454


Given two strings S1 and S2. Delete from S2 all those characters which occur in S1 also and finally create a clean S2 with the relevant characters deleted.

834


What does c mean in standard form?

596


What is the use of #include in c?

574


Write an efficient algo and C code to shuffle a pack of cards.. this one was a feedback process until we came up with one with no extra storage.

660


Give a one-line C expression to test whether a number is a power of 2. [No loops allowed - it's a simple test.]

631


c language interview questions & answer

1458


What is a program flowchart and explain how does it help in writing a program?

673