Sum of N numbers program in C: Using for loop

Let’s discuss the program for sum of N numbers in C Programming Language using the While Loop.

C Program to find Sum of N Numbers


int main()

  int Number, i, Sum = 0;
  printf("\nPlease Enter any Integer Value\n");
  scanf("%d", &Number);
    for(i = 1; i <= Number; i++)
     Sum = Sum + i;
   printf("Sum of Natural Numbers = %d", Sum);
  return 0;

Leave a Comment

Your email address will not be published. Required fields are marked *