top of page
Wave
Cactus%20Plant_edited.jpg

S = 1 - 2 + 3 - 4 ... ± N

#include<stdio.h>
int main()
{
    int i,n,s=0,j=1;
    printf("Enter the value of n: ");
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        s=s+(i*j);
        j=(j*(-1));
    }
    printf("Answer is => %d",s);
    return 1;
}

Subscribe Form

Thanks for submitting!

  • Facebook
  • YouTube
  • Instagram
  • Twitter

©2020 by Abhisek Midya ( A18 )

bottom of page