Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

Why shouldn’t I start variable names with underscores?

1008


How do I get a null pointer in my programs?

1062


What are the complete rules for header file searching?

1032


What does c in a circle mean?

1024


What was noalias and what ever happened to it?

980


What is s or c?

1017


How can I call fortran?

998


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

1068


What is extern keyword in c?

1086


What do you mean by dynamic memory allocation in c?

1053


Explain how can you determine the size of an allocated portion of memory?

1044


Is flag a keyword in c?

1111


Explain pointers in c programming?

1066


Tell me about low level programming languages.

1069


What does %d do in c?

913