CODE BOX
Pages
Home
Data Types
Algorithms
Easy Find
Linux Commands
Sunday, 4 October 2015
WAP for the following series.
1^2 - 3^2 + 5^2 - 7^2 + - - - - - - - - +101^2
CODE ::
#include <stdio.h>
int main ()
{
int i,sum=0,sign=1;
for(i=1;i<=101;i=i+2)
{
sum=sum+(i*i)*(sign);
sign=sign*(-1);
}
printf("Sum is %d",sum);
return 0;
}
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment