Tuesday, 5 September 2017

C-Program for Sum of N numbers



#include<stdio.h>

int main()
{
  int i,n,sum=0;
  printf("Enter a number\n");
  scanf("%d",&n);
  for(i=0;i<=n;i++)
  {
    sum=sum+i;
  }
  printf("%d\n",sum);
return 0;
}

No comments:

Post a Comment