Sum of N numbers program in C: Using While 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 using While Loop

#include<stdio.h>
//Learn C Programming at codeatglance.com
int main()
{
  int Num, i = 1, Sum = 0;
    printf("\nEnter any Integer Value\n");
  scanf("%d", &Num);
  
  while(i <= Num)
  {
     Sum = Sum + i;
     i++;
  }
  
  printf("Sum of N Numbers = %d", Sum);
  return 0;
}

Leave a Reply

Shopping cart