Problem 30: Series sum

Write a program which will print the summation of the given series-
101 + 99 + 97 + …….. + 3 + 1 = ?

 

2,835 total views, 2 views today

Comments

comments

4 thoughts on “Problem 30: Series sum”

  1. #include
    #include

    int main()
    {
    int i, sum=0;
    for (i=101; i>=0;i=i-2)
    {
    printf(“%d\t”,i);
    sum = sum+i;
    }
    printf(“\n\n \t \t \t Sum is = %d”,sum);

    getch();
    return 0;
    }

  2. #include
    int main()
    {
    int n,sum=0;
    n=101;
    while(n>=1){
    sum=sum+n;
    n=n-2;
    }
    printf(“%d\n”,sum);
    return 0;
    }

  3. #include
    int main()
    {
    int i,sum=0;
    for(i=101;i>=1;i=i-2){
    printf(“%d\n”,i);
    sum=sum+i;
    }

    }

  4. #include

    int main()
    {
    int x=0;
    int sum=0;

    for(x=101;x>=1;x=(x-2)){
    sum=sum+x;
    continue ;
    }
    printf(“The total summation is: %d \n”,sum);

    return 0;
    }

Leave a Reply

Your email address will not be published.