Computer Science, asked by sabyasachi73, 1 year ago

WRITE A Q BASIC PROGRAM ON THE TOPIC - TO ADD NATURAL NUMBERS FROM 1 TO 20

Answers

Answered by amankumarrai2005
2

Answer:

The positive numbers 1, 2, 3... are known as natural numbers. The sum of natural numbers up to 10 is:

sum = 1 + 2 + 3 + � + 10

Sum of Natural Numbers Using for Loop

#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;

}

Explanation:

hope it help mark as brain least

Similar questions