#include <stdio.h>
int main() {
int limit,a=1,s=0;
printf("\nEnter how many natural no you want to sum:\n");
scanf("%d",&limit);
while(a<=limit)
{ printf("\n%5d",a);
s=s+a;
a++;
}
printf("\n Sum of %d natural nos. is %d",limit,s);
return 0;
}
To embed this program on your website, copy the following code and paste it into your website's HTML: