#include<stdio.h> #include<conio.h> main() { int n,i=0,sum=0; clrscr( ); printf("Enter Limit : "); scanf("%d",&n); while(i<n) { i++; sum+=i; } printf("Sum of %d natural numbers = %d",n,sum); getch(); }
OUTPUT:
Enter Limit : 10 Sum of 10 natural numbers = 55