Write a program for the following series:
1*3*5-2*4*6+3*5*7-4*6*8+.................up to nterms

Answers were Sorted based on User's Feedback



Write a program for the following series: 1*3*5-2*4*6+3*5*7-4*6*8+.................up to nterms..

Answer / 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

Write a program for the following series: 1*3*5-2*4*6+3*5*7-4*6*8+.................up to nterms..

Answer / sri k. hari

/* Author : Sri K. Hari
Description : program for series
1*3*5-2*4*6+3*5*7-4*6*8...........upto n terms
*/

#include<stdio.h>
#include<conio.h>

void main()
{
int n,i,res,finres;
char opt ;
clrscr () ;
do
{
res = 0 ;
finres = 0 ;
printf ( " \n Enter the last number " ) ;
scanf("%d",&n);

for ( i = 1 ; i <= n ;i++ )
{
res = ( i * (i+2) * (i+4) ) ;

if ( (i%2) == 0 )
finres = finres - res ;
else
finres = finres + res ;
}
printf ( " \n the result is : %d ", finres) ;
printf ( "Do you want to continue (Y/N)" ) ;
scanf ( "%s",&opt) ;
}while ( (opt == 'y' ) || (opt == 'Y' ) ) ;
}

Is This Answer Correct ?    1 Yes 0 No

Write a program for the following series: 1*3*5-2*4*6+3*5*7-4*6*8+.................up to nterms..

Answer / 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

Write a program for the following series: 1*3*5-2*4*6+3*5*7-4*6*8+.................up to nterms..

Answer / guest

#include<iosteram.h>
#include<conio.h>
int seri(int)
{
int r,s;
r=s*m+var;
return r;
}
void main()
{
int a[20],b[20];
cin>>n;
for(int i=1;i<=n;i++)
{
cin>>a[i];
int var=-1;
m=a[i];
cout<<m;
getch();
}

Is This Answer Correct ?    1 Yes 1 No

Write a program for the following series: 1*3*5-2*4*6+3*5*7-4*6*8+.................up to nterms..

Answer / y hussain reddy

#include<stdio.h>
#include<conio.h>
#include<math.h>

void main()
{
int i,p,n;
long s=0;
puts("nter n\n");
scanf("%d",&n);
for(i=1;i<=n;i++)
{p=pow(-1,i-1);
s+=i*(i+2)*(i+4)*p;
}
printf("ans=%ld",s);
}

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C Interview Questions

What is the general form of #line preprocessor?

0 Answers  


what are the advantage of pointer variables? write a program to count the number of vowels and consonants in a given string

3 Answers  


write a program to create a sparse matrix using dynamic memory allocation.

0 Answers  


what is the value of b if a=5; b=++a + ++a

31 Answers   Infosys, TCS, Tech Mahindra,


we compile c program in 32 processor and 64 bit processor .exe file is created in both the processors. if we want to run .exe file in 64 bit processor which is created in 32 bit processor. is that .exe file is run or not if it is not run why?

4 Answers   HP, Wipro,






What is a char c?

0 Answers  


Is there any data type in c with variable size?

0 Answers  


Explain what is the advantage of a random access file?

0 Answers  


code for concatination of 2 strings with out using library functions?

3 Answers  


What does nil mean in c?

0 Answers  


how to find your architecture is LittleEndian or BigEndian?

1 Answers  


#include<stdio.h> main() { int i=5; printf("%d",i*i-- - --i*i*i++ + ++i); } tell the answer with correct reason .specially reason is important nt answer ans by turbo c is -39

1 Answers   GameLoft,


Categories