# How to Calculate the Sum of Natural Numbers Using C Program?

Hello friends, today I will tell you through this tutorials how you can calculate sum natural numbers through c program language. So let’s go.

The positive numbers 1, 2, 3… are known as natural numbers. The sum of natural numbers up to 10 is: You can calculate sum natural number in 2 ways.

1. C for Loop
2. C while Loop

## Sum of Natural Numbers Using for Loop

The first method is that you can easily calculate the sum natural number through the c program via for loop. Now you are told by the example below. How you can sum sum natural numbers with the help of for loop Can calculate by c language.

```#include <stdio.h>
int main() {
int n, i, sum = 0;
printf("Enter a positive integer: ");
scanf("%d", &n);
for (i = 1; i <= n; ++i) {
sum += i;
}
printf("Sum = %d", sum);
return 0;
}```

## Sum of Natural Numbers Using while Loop

The second method is that you can easily calculate the sum natural number through the c program via while loop. Now you are told by the example below. How you can sum sum natural numbers with the help of while loop Can calculate by c language.

```#include <stdio.h>
int main() {
int n, i, sum = 0;
printf("Enter a positive integer: ");
scanf("%d", &n);
i = 1;
while (i <= n) {
sum += i;
++i;
}
printf("Sum = %d", sum);
return 0;
}```

### Output

```Enter a positive integer: 100
Sum = 5050```
Cialis (Tadalafil) är den främsta konkurrenten till Viagra (Sildenafil) på marknaden för erektil dysfunktion. köpa Cialis i Sverige föredras av många på grund av sin längre varaktighet och anses vara det mest kostnadseffektiva varumärkesbaserade ED-läkemedlet som finns tillgängligt i Sverige. Cialis finns i två varianter: Cialis och Cialis Daily, och fyra olika doseringar: 2,5 mg, 5 mg, 10 mg och 20 mg, erbjuder Cialis också en rad olika alternativ för att passa patientens behov.