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


Please Help Members By Posting Answers For Below Questions

WRITE A CODE IN C TO SEARCH A FILE FROM NOTEPAD FILE.

2026


What is the difference between typedef and #define?

545


Is it better to use malloc() or calloc()?

649


What are the ways to a null pointer can use in c programming language?

590


Hello. How to write a C program to check and display president party like if i type in the console "biden" and hit enter the output shoud be : "biden is democrat" and if i type "trump" and hit enter the output shoud be: "trump is republican"

1582






Can we initialize extern variable in c?

632


find the value of y y = 1.5x+3 for x<=2 y = 2x+5 for x>2

1526


What is wrong with this initialization?

593


What are 'near' and 'far' pointers?

620


Differentiate between a structure and a union.

763


hi friends how r u as soon in satyam my interview is start but i m very confusued ta wat i do plz help me frndz wat can i do plz tell me some question and answers related with "C" which r asked in the interview .

1901


Explain what is a 'null pointer assignment' error? Explain what are bus errors, memory faults, and core dumps?

643


Can you think of a logic behind the game minesweeper.

2008


Discuss the function of conditional operator, size of operator and comma operator with examples.

678


Write a C/C++ program that connects to a MySQL server and checks if the InnoDB plug-in is installed on it. If so, your program should print the maximum number of concurrent threads that the InnoDB plug-in can create.

1477