Write a program for the following series:
1*3*5-2*4*6+3*5*7-4*6*8+.................up to nterms
Answer Posted / 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 |
Post New Answer View All Answers
What is the process to generate random numbers in c programming language?
What is hashing in c language?
What does 3 mean in texting?
please send me the code for multiplying sparse matrix using c
Which is more efficient, a switch statement or an if else chain?
Explain the bubble sort algorithm.
Explain Basic concepts of C language?
What is the purpose of the statement: strcat (S2, S1)?
explain what is a newline escape sequence?
What are the types of data structures in c?
What is character constants?
how to print electricity bill according to following charges first 100 units -1rs per unit for next 200 units-1.50 rs per unit without using conditions
Why array is used in c?
What is meant by initialization and how we initialize a variable?
What is the need of structure in c?