CODE BOX
Pages
Home
Data Types
Algorithms
Easy Find
Linux Commands
Sunday, 4 October 2015
WAP for the following series.
1-3+5-7+9-11+ --------------------+101
CODE ::
#include <stdio.h>
int main ()
{
int i,sum,sign;
sum=0;
sign=1;
for(i=1;i<=101;i=i+2)
{
sum=sum+i*sign;
sign=sign*(-1);
}
printf("Summ 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