Write a program for the following series:
1*3*5-2*4*6+3*5*7-4*6*8+.................up to nterms
Answer Posted / anshu porwal
#include<stdio.h>
#include<conio.h>
void main()
{
int x=1,y=3,z=5,n,cal,add=0,add1=0,total,i;
clrscr();
printf(" Enter Any Number to calculate Series for n
terms :");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
cal=(x*y*z);
x++;
y++;
z++;
if(i%2==1)
{
add=add+cal;
}
if(i%2==0)
{
add1=add1+cal;
}
}
total=add-add1;
printf(" Total Of Series Is %d",total);
getch();
}
| Is This Answer Correct ? | 1 Yes | 1 No |
Post New Answer View All Answers
What is the use of gets and puts?
Why doesnt long int work?
How can I get random integers in a certain range?
what value is returned to operating system after program execution?
#include
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
Explain what is the use of a semicolon (;) at the end of every program statement?
what is event driven software and what is procedural driven software?
What is the maximum length of an identifier?
What is chain pointer in c?
How do I get an accurate error status return from system on ms-dos?
What are pointers in C? Give an example where to illustrate their significance.
what is uses of .net
How will you delete a node in DLL?
What is a stream water?