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
program to find error in linklist.(i.e find whether any node point wrongly to previous nodes instead of next node)
How can I send mail from within a c program?
What is a buffer in c?
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?
How can you find the day of the week given the date?
What is dynamic dispatch in c++?
while initialization of array why we use a[][2] why not a[2][]...?
write a program to display all prime numbers
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.
What does c mean in standard form?
What is the use of #include in c?
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.
Give a one-line C expression to test whether a number is a power of 2. [No loops allowed - it's a simple test.]
c language interview questions & answer
What is a program flowchart and explain how does it help in writing a program?