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
Explain how many levels deep can include files be nested?
Why c is known as a mother language?
Write a program with dynamically allocation of variable.
Explain how do you use a pointer to a function?
writ a program to compare using strcmp VIVA and viva with its output.
Why & is used in c?
What is the code in while loop that returns the output of given code?
Dont ansi function prototypes render lint obsolete?
What is the purpose of scanf() and printf() functions?
Why we use break in c?
how to solve "unable to open stdio.h and conio.h header files in windows 7 by using Dos-box software
How can I sort a linked list?
shorting algorithmS
Explain what is a pragma?
What is huge pointer in c?