RakeshMgs

Sum of First n Natural numbers

 

Sum of First n Natural numbers

#include <stdio.h> int main() { int n, count, sum = 0; printf("Enter the value of n(positive integer): "); scanf("%d",&n); for(count=1; count <= n; count++) { sum = sum + count; } printf("Sum of first %d natural numbers is: %d",n, sum); return 0; }

output

Sum of First n Natural numbers


आपको आर्टिकल कैसा लगा? अपनी राय अवश्य दें
Please don't Add spam links,
if you want backlinks from my blog contact me on rakeshmgs.in@gmail.com