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

What is extern variable in c with example?

547


Differentiate between declaring a variable and defining a variable?

614


When should we use pointers in a c program?

640


List the difference between a 'copy constructor' and a 'assignment operator' in C?

647


What is extern c used for?

576






In C language, a variable name cannot contain?

752


any function have arguments one or more OR not . it is compulsary a) any function compulsary have one or more arguments b) any function did not have arguments. It is not compulsary c) it is optional it is not compulsary d) none of the above

649


How is a pointer variable declared?

601


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?

1779


The % symbol has a special use in a printf statement. Explain how would you place this character as part of the output on the screen?

670


Is null always defined as 0(zero)?

619


Are c and c++ the same?

635


How do I get an accurate error status return from system on ms-dos?

653


What do you mean by c what are the main characteristics of c language?

576


Write a program to print "hello world" without using a semicolon?

602