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
Explain Basic concepts of C language?
What is the difference between declaring a variable and defining a variable?
Differentiate between ordinary variable and pointer in c.
Explain what is wrong with this statement? Myname = ?robin?;
What is a pointer on a pointer in c programming language?
Can a variable be both const and volatile?
hi send me sample aptitude papers of cts?
What is the difference between call by value and call by reference in c?
What is self-referential structure in c programming?
What is the default value of local and global variables in c?
Why do we need functions in c?
can anyone please tell about the nested interrupts?
On most computers additional memory that is accessed through an adapter of feature card along with a device driver program. a) user memory b) conventional memory c) expandedmemory d) area
What is the difference between array and pointer?
What are preprocessor directives in c?