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 extern variable in c with example?
Differentiate between declaring a variable and defining a variable?
When should we use pointers in a c program?
List the difference between a 'copy constructor' and a 'assignment operator' in C?
What is extern c used for?
In C language, a variable name cannot contain?
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
How is a pointer variable declared?
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?
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?
Is null always defined as 0(zero)?
Are c and c++ the same?
How do I get an accurate error status return from system on ms-dos?
What do you mean by c what are the main characteristics of c language?
Write a program to print "hello world" without using a semicolon?