Search:

Submit Article

# PROGRAM TO FIND ANSWER OF THE FOLLOWING SERIES. INPUT STEPS FROM KEYBOARD. SUM =12-32+52-72+.....

Posted By: Verene Fischer     Category: C Programming     Views: 3697

## Code for PROGRAM TO FIND ANSWER OF THE FOLLOWING SERIES. INPUT STEPS FROM KEYBOARD. SUM =12-32+52-72+..... in C Programming

```void main()
{
longint n,i,j,sum=0;
clrscr();
printf("\n PLEASE ENTER THE VALUE OF N: ");
scanf("%ld",&n);
printf("\n SUM = ");
for(j=1,i=12;j<=n;i=i+20,j++)
{
if(j%2==1)
{
sum=sum+i;
if(j==n)
printf("%ld",i);
else
printf("%ld - ",i);
}
else
{
sum=sum-i;
if(j==n)
printf("%ld",i);
else
printf("%ld + ",i);
}
}
printf("\n\n THE SUM IS %ld",sum);

getch();
}

**************************** OUTPUT *********************************

PLEASE ENTER THE VALUE OF N: 9

SUM = 12 - 32 + 52 - 72 + 92 - 112 + 132 - 152 + 172

THE SUM IS 92

*********************************************************************
```
Share:

 Verene Fischer author of PROGRAM TO FIND ANSWER OF THE FOLLOWING SERIES. INPUT STEPS FROM KEYBOARD. SUM =12-32+52-72+..... is from Frankfurt, Germany. View All Articles

 Please enter your CommentComment should be atleast 30 Characters.Please put code inside [Code] your code [/Code]. No Comment Found, Be the First to post comment!