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
Is it possible to use curly brackets ({}) to enclose single line code in c program?
Explain how do you determine a file’s attributes?
7-Given an index k, return the kth row of the Pascal's triangle. For example, when k = 3, the row is [1,3,3,1]. For reference look at the following standard pascal’s triangle.
how to write optimum code to divide a 50 digit number with a 25 digit number??
the number of measuring units from a arbitrary starting point in a record area or control block to some other point a) branching b) recording pointer c) none d) offset
What is typedef example?
Can the size of an array be declared at runtime?
What is realloc in c?
What are the different types of errors?
Why c is called object oriented language?
Differentiate between #include<...> and #include '...'
What is the purpose of main( ) in c language?
What does malloc () calloc () realloc () free () do?
With the help of using classes, write a program to add two numbers.
Explain what is operator promotion?